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
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
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.
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.
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)
33 + # Link quality multiplier is used only when
34 + # LinkQualityLevel is > 0.
36 + # LinkQualityMult 192.168.0.1 0.5
38 + # This multiplier applies to all other nodes
39 + # LinkQualityMult default 0.8
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
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
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.
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.
67 # A multiplier of 0.5 will result in a small
68 # (bad) LinkQuality value and a high (bad)
71 + # Link quality multiplier is used only when
72 + # LinkQualityLevel is > 0.
74 # LinkQualityMult 192.168.0.1 0.5
76 # This multiplier applies to all other nodes
77 # LinkQualityMult default 0.8
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
88 # HnaValidityTime 15.0
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
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.
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.
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)
115 + # Link quality multiplier is used only when
116 + # LinkQualityLevel is > 0.
118 + # LinkQualityMult 192.168.0.1 0.5
120 + # This multiplier applies to all other nodes
121 + # LinkQualityMult default 0.8
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
130 static const char *httpinfo_css[] =
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
142 size += sprintf(&buf[size], "<h2>OLSR routes in kernel</h2>\n");
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");
151 for(index = 0;index < HASHSIZE;index++)
152 @@ -722,12 +725,23 @@
153 routes != &routingtable[index];
154 routes = routes->next)
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),
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>"
166 + olsr_ip_to_string(&routes->rt_dst),
168 + olsr_ip_to_string(&routes->rt_dst),
169 + olsr_ip_to_string(&routes->rt_router),
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],
177 + "<td>HOST</td></tr>\n",
178 + routes->rt_if->int_name);
182 @@ -738,11 +752,21 @@
183 routes != &hna_routes[index];
184 routes = routes->next)
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),
190 - routes->rt_if->int_name);
191 + size += sprintf(&buf[size],
193 + "<td><a href=\"http://%s:%d/all\">%s</a></td>"
195 + olsr_ip_to_string(&routes->rt_dst),
196 + olsr_ip_to_string(&routes->rt_router),
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],
204 + "<td>HNA</td></tr>\n",
205 + routes->rt_if->int_name);
209 @@ -816,17 +840,24 @@
211 size += sprintf(&buf[size], "</tr>\n<tr>\n");
213 - size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
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)
219 + size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
220 + if (olsr_cnf->use_hysteresis)
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);
227 size += sprintf(&buf[size], "</tr>\n<tr>\n");
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)
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);
240 size += sprintf(&buf[size], "</tr></table>\n");
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");
249 size += sprintf(&buf[size], "</table>\n");
250 @@ -950,21 +980,39 @@
251 int size = 0, index, thop_cnt;
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");
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],
275 + "<td><a href=\"http://%s:%d/all\">%s</a></td>"
277 + olsr_ip_to_string(&link->local_iface_addr),
278 + olsr_ip_to_string(&link->neighbor_iface_addr),
280 + olsr_ip_to_string(&link->neighbor_iface_addr),
281 + link->L_link_quality);
282 + if (olsr_cnf->lq_level > 0)
284 + size += sprintf(&buf[size],
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);
296 + size += sprintf(&buf[size], "</tr>\n");
300 @@ -981,7 +1029,13 @@
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>"
310 + olsr_ip_to_string(&neigh->neighbor_main_addr),
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;
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");
327 @@ -1035,12 +1092,26 @@
328 dst_entry = entry->destinations.next;
329 while(dst_entry != &entry->destinations)
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),
342 + olsr_ip_to_string(&dst_entry->T_dest_addr),
343 + olsr_ip_to_string(&entry->T_last_addr),
345 + olsr_ip_to_string(&entry->T_last_addr));
346 + if (olsr_cnf->lq_level > 0)
348 + size += sprintf(&buf[size],
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);
356 + size += sprintf(&buf[size], "</tr>\n");
358 dst_entry = dst_entry->next;
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),
368 olsr_ip_to_string(&tmp_hna->A_gateway_addr));
369 tmp_net = tmp_net->next;
371 @@ -1101,7 +1174,7 @@
373 build_mid_body(char *buf, olsr_u32_t bufsize)
376 + int size = 0, mid_cnt;
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])
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),
388 + olsr_ip_to_string(&entry->main_addr));
389 size += sprintf(&buf[size], "<td><select>\n<option>IP ADDRESS</option>\n");
391 alias = entry->aliases;
395 size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&alias->alias));
397 alias = alias->next_alias;
399 - size += sprintf(&buf[size], "</select>\n");
401 - size += sprintf(&buf[size], "</tr>\n");
402 + size += sprintf(&buf[size], "</select> (%d)</td></tr>\n", mid_cnt);
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
411 #include "olsrd_httpinfo.h"
415 static void __attribute__ ((constructor))
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
422 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
423 #define PLUGIN_INTERFACE_VERSION 4
426 +extern int http_port;
428 /* Allowed hosts stuff */
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
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)
451 fprintf(fd, " Weight\t %d\n\n", in->cnf->weight.value);
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")
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")
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");
472 if(in->cnf->weight.fixed)
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
479 #define MAXMESSAGESIZE 1500 /* max broadcast size */
480 #define UDP_IPV4_HDRSIZE 28
481 #define UDP_IPV6_HDRSIZE 48
485 /* Debug helper macro */
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
491 if (!COMP_IP(&walker->neighbor->neighbor_main_addr, main_addr))
494 - // handle the non-LQ case
495 + // handle the non-LQ, RFC-compliant case
497 if (olsr_cnf->lq_level == 0)
503 - // handle the LQ case
504 + // handle the LQ, non-RFC compliant case
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))
516 tmp_link_set = tmp_link_set->next;
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
528 + /*COPY_IP(&neighbor->neighbor_main_addr, remote_main);*/
530 neighbor->linkcount++;
533 * We'll go for one that is hopefully long
534 * enough in most cases. 10 seconds
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.
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);
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
555 #include <netinet/in.h>
556 #include "../olsr_protocol.h"
558 -#define MAXIFS 8 /* Maximum number of network interfaces */
559 +#include "../defs.h" /* MAX_IFS */
561 /* Redirect proc entry */
562 #define REDIRECT_PROC "/proc/sys/net/ipv4/conf/%s/send_redirects"
564 struct nic_state *next;
567 -struct nic_state nic_states[MAXIFS];
568 +struct nic_state nic_states[MAX_IFS];
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
580 +find_local_hna4_entry(union olsr_ip_addr *net, olsr_u32_t mask)
582 + struct hna4_entry *h4 = olsr_cnf->hna4_entries;
586 + if((net->v4 == h4->net.v4) &&
587 + (mask == h4->netmask.v4))
600 +find_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len)
602 + struct hna6_entry *h6 = olsr_cnf->hna6_entries;
606 + if((memcmp(net, &h6->net, ipsize) == 0) &&
607 + (prefix_len == h6->prefix_len))
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
626 remove_local_hna6_entry(union olsr_ip_addr *, olsr_u16_t);
629 +find_local_hna4_entry(union olsr_ip_addr *net, olsr_u32_t mask);
632 +find_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len);
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
641 struct neighbor_list_entry *walker;
643 struct neighbor_entry *neigh;
645 + double best, best_1hop;
646 olsr_bool mpr_changes = OLSR_FALSE;
647 struct link_entry *link;
650 neigh2 != &two_hop_neighbortable[i];
651 neigh2 = neigh2->next)
655 // check whether this 2-hop neighbour is also a neighbour
657 neigh = olsr_lookup_neighbor_table(&neigh2->neighbor_2_addr);
658 @@ -110,14 +112,14 @@
662 - best = link->loss_link_quality * link->neigh_link_quality;
663 + best_1hop = link->loss_link_quality * link->neigh_link_quality;
665 // see wether we find a better route via an MPR
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)
674 // we've reached the end of the list, so we haven't found
676 best = walker->path_link_quality;
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))
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
691 #include "scheduler.h"
692 #include "neighbor_table.h"
693 #include "link_set.h"
694 +#include "packet.h" /* struct mid_alias */
697 struct mid_entry mid_set[HASHSIZE];
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;
704 hash = olsr_hashing(m_addr);
705 alias_hash = olsr_hashing(&alias->alias);
708 if(COMP_IP(&tmp->main_addr, m_addr))
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))
716 + /* Alias is already registered with main address. Nothing to do here. */
721 /*If the address was registered*/
722 if(tmp != &mid_set[hash])
726 if(COMP_IP(&tmp_list->main_addr, adr))
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);
738 + *Remove aliases from 'entry' which are not listed in 'declared_aliases'.
740 + *@param entry the MID entry
741 + *@param declared_aliases the list of declared aliases for the MID entry
746 +olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases)
748 + struct mid_entry *entry;
750 + struct mid_address *registered_aliases;
751 + struct mid_address *previous_alias;
752 + struct mid_alias *save_declared_aliases = declared_aliases;
754 + hash = olsr_hashing(m_addr);
756 + /* Check for registered entry */
757 + for(entry = mid_set[hash].next;
758 + entry != &mid_set[hash];
759 + entry = entry->next)
761 + if(COMP_IP(&entry->main_addr, m_addr))
764 + if(entry == &mid_set[hash])
766 + /* MID entry not found, nothing to prune here */
770 + registered_aliases = entry->aliases;
771 + previous_alias = NULL;
773 + while(registered_aliases != 0)
775 + struct mid_address *current_alias = registered_aliases;
776 + registered_aliases = registered_aliases->next_alias;
778 + declared_aliases = save_declared_aliases;
780 + /* Go through the list of declared aliases to find the matching current alias */
781 + while(declared_aliases != 0 &&
782 + ! COMP_IP(¤t_alias->alias, &declared_aliases->alias_addr))
784 + declared_aliases = declared_aliases->next;
787 + if (declared_aliases == 0)
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(¤t_alias->alias))
793 + /* Update linked list as seen by 'entry' */
794 + if (previous_alias != NULL)
796 + previous_alias->next_alias = current_alias->next_alias;
800 + entry->aliases = current_alias->next_alias;
803 + /* Remove from hash table */
804 + DEQUEUE_ELEM(current_alias);
806 + free(current_alias);
809 + *Recalculate topology
811 + changes_neighborhood = OLSR_TRUE;
812 + changes_topology = OLSR_TRUE;
816 + previous_alias = current_alias;
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
829 extern struct mid_entry mid_set[HASHSIZE];
830 extern struct mid_address reverse_mid_set[HASHSIZE];
835 olsr_init_mid_set(void);
838 olsr_time_out_mid_set(void *);
841 +olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases);
844 olsr_update_mid_table(union olsr_ip_addr *, float);
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 @@
851 if (olsr_cnf->debug_level > 3)
853 - olsr_print_duplicate_table();
854 + if (olsr_cnf->debug_level > 8)
856 + olsr_print_duplicate_table();
858 olsr_print_hna_set();
862 olsr_print_link_set();
863 olsr_print_neighbor_table();
864 + olsr_print_two_hop_neighbor_table();
865 olsr_print_tc_table();
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
873 #include "duplicate_set.h"
874 #include "rebuild_packet.h"
875 +#include "local_hna_set.h"
880 tmp_adr = tmp_adr->next;
883 + olsr_prune_aliases(&message.mid_origaddr, message.mid_addr);
886 olsr_forward_message(m,
887 &message.mid_origaddr,
892 - olsr_update_hna_entry(&message.originator, &hna_tmp->net, &hna_tmp->netmask, (float)message.vtime);
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))
898 + olsr_update_hna_entry(&message.originator, &hna_tmp->net, &hna_tmp->netmask, (float)message.vtime);
901 hna_tmp = hna_tmp->next;
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
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;
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.
922 + if (olsr_cnf->lq_level > 0)
924 + // loop through the one-hop neighbors that see this
925 + // 'two_hop_neighbor'
927 + struct neighbor_list_entry *walker;
929 + for (walker = two_hop_neighbor->neighbor_2_nblist.next;
930 + walker != &two_hop_neighbor->neighbor_2_nblist;
931 + walker = walker->next)
933 + // have we found the one-hop neighbor that sent the
934 + // HELLO message that we're current processing?
936 + if (walker->neighbor == neighbor)
938 + walker->path_link_quality = 0.0;
945 @@ -586,19 +619,48 @@
946 (float)message->vtime);
952 - if (olsr_cnf->lq_level > 0)
953 + // Separate, second and third pass for link quality OLSR
955 + if (olsr_cnf->lq_level > 0)
957 + struct link_entry *link =
958 + get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
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.
970 + for(message_neighbors = message->neighbors;
971 + message_neighbors != NULL;
972 + message_neighbors = message_neighbors->next)
974 + if(if_ifwithaddr(&message_neighbors->address) != NULL)
977 + if(((message_neighbors->status == SYM_NEIGH) ||
978 + (message_neighbors->status == MPR_NEIGH)))
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);
987 - link = get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
988 + if(!two_hop_neighbor_yet)
993 + two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
995 // loop through the one-hop neighbors that see this
996 - // two hop neighbour
997 + // 'two_hop_neighbor'
999 for (walker = two_hop_neighbor->neighbor_2_nblist.next;
1000 walker != &two_hop_neighbor->neighbor_2_nblist;
1001 @@ -609,14 +671,7 @@
1003 if (walker->neighbor == neighbor)
1005 - double saved_lq, rel_lq;
1007 - // saved previous total link quality
1009 - saved_lq = walker->saved_path_link_quality;
1011 - if (saved_lq == 0.0)
1013 + double new_second_hop_link_quality, new_path_link_quality;
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
1021 - walker->second_hop_link_quality =
1022 + new_second_hop_link_quality =
1023 message_neighbors->link_quality *
1024 message_neighbors->neigh_link_quality;
1026 // the total quality for the route
1027 // "us --- 1-hop --- 2-hop"
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;
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)
1040 + walker->second_hop_link_quality = new_second_hop_link_quality;
1041 + walker->path_link_quality = new_path_link_quality;
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)
1056 + if(if_ifwithaddr(&message_neighbors->address) != NULL)
1059 + if(((message_neighbors->status == SYM_NEIGH) ||
1060 + (message_neighbors->status == MPR_NEIGH)))
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);
1067 + if(!two_hop_neighbor_yet)
1070 + two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
1072 + // loop through the one-hop neighbors that see this
1073 + // 'two_hop_neighbor'
1075 + for (walker = two_hop_neighbor->neighbor_2_nblist.next;
1076 + walker != &two_hop_neighbor->neighbor_2_nblist;
1077 + walker = walker->next)
1079 + // have we found the one-hop neighbor that sent the
1080 + // HELLO message that we're current processing?
1082 + if (walker->neighbor == neighbor)
1084 + double saved_lq, rel_lq;
1086 + // saved previous total link quality
1088 + saved_lq = walker->saved_path_link_quality;
1090 + if (saved_lq == 0.0)
1093 + // if the link cost has changed by more than 10
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
1101 olsr_fill_routing_table_with_two_hop_neighbors(void);
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);
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);
1112 two_hop_neighbor_reachable(struct neighbor_2_list_entry *);
1113 @@ -212,7 +212,12 @@
1114 new_route_entry->rt_if = iface;
1116 new_route_entry->rt_metric = metric;
1117 - new_route_entry->rt_etx = etx;
1120 + new_route_entry->rt_etx = (float)metric;
1123 + new_route_entry->rt_etx = etx;
1125 if(COMP_IP(dst, router))
1128 &link->neighbor_iface_addr,
1137 &link->neighbor_iface_addr,
1143 if(new_route_entry != NULL)
1146 &list_destination_n->destination->rt_router,
1147 list_destination_n->destination->rt_if,
1148 list_destination_n->destination->rt_metric+1,
1151 if(destination_n_1->destination != NULL)
1153 destination_n_1->next=list_destination_n_1;
1154 @@ -549,17 +554,17 @@
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
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
1167 - *@return the localted entry if found. NULL if not
1168 + *@return the located entry if found. NULL if not
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)
1177 if(COMP_IP(&tmp_routes->rt_dst, &net->A_network_addr) &&
1178 (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
1180 - /* Found a entry */
1181 - if(tmp_routes->rt_metric > metric)
1182 + /* Found an entry */
1183 + if(tmp_routes->rt_etx < etx)
1187 @@ -589,17 +594,17 @@
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
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
1200 - *@return the localted entry if found. NULL if not
1201 + *@return the located entry if found. NULL if not
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)
1210 if(COMP_IP(&tmp_routes->rt_dst, &net->A_network_addr) &&
1211 (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
1213 - /* Found a entry */
1214 - if(tmp_routes->rt_metric <= metric)
1215 + /* Found an entry */
1216 + if(tmp_routes->rt_etx >= etx)
1220 @@ -672,13 +677,13 @@
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)
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)
1239 COPY_IP(&new_rt->rt_router, &tmp_rt->rt_router);
1241 + new_rt->rt_etx = tmp_rt->rt_etx;
1242 new_rt->rt_metric = tmp_rt->rt_metric;
1244 new_rt->rt_flags = RTF_UP | RTF_GATEWAY;
1247 COPY_IP(&new_rt->rt_router, &tmp_rt->rt_router);
1249 + new_rt->rt_etx = tmp_rt->rt_etx;
1250 new_rt->rt_metric = tmp_rt->rt_metric;
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))
1261 + ifp->int_addr = ifr.ifr_addr;
1263 if(memcmp(&main_addr,
1264 - &((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
1268 OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr))
1273 - ifp->int_addr = ifr.ifr_addr;
1274 memcpy(&ifp->ip_addr,
1275 &((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
1278 ifs.if_index = if_nametoindex(ifr.ifr_name);
1280 /* Set interface metric */
1281 - /* Set interface metric */
1282 if(iface->cnf->weight.fixed)
1283 ifs.int_metric = iface->cnf->weight.value;