1 diff -Nur olsrd-0.4.10.orig/src/main.c olsrd-0.4.10/src/main.c
2 --- olsrd-0.4.10.orig/src/main.c 2005-09-29 07:53:34.000000000 +0200
3 +++ olsrd-0.4.10/src/main.c 2006-12-01 09:10:15.000000000 +0100
5 /* Initialize parser */
8 + /* Initialize route-exporter */
9 + olsr_init_export_route();
11 /* Initialize message sequencnumber */
14 diff -Nur olsrd-0.4.10.orig/src/process_routes.c olsrd-0.4.10/src/process_routes.c
15 --- olsrd-0.4.10.orig/src/process_routes.c 2005-05-30 15:13:38.000000000 +0200
16 +++ olsrd-0.4.10/src/process_routes.c 2006-12-01 09:10:15.000000000 +0100
18 * Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org)
19 * All rights reserved.
21 + * export_route_entry interface added by Immo 'FaUl Wehrenberg
22 + * <immo@chaostreff-dortmund.de>
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
28 * $Id: process_routes.c,v 1.27 2005/05/30 13:13:38 kattemat Exp $
36 #define strerror(x) StrError(x)
39 +struct export_route_entry
41 + olsr_u8_t type; /* AF_INET/AF_INET6 */
42 + int (*function)(struct rt_entry*);
43 + struct export_route_entry *next;
47 +static struct export_route_entry *add_routes;
48 +static struct export_route_entry *del_routes;
51 struct rt_entry old_routes[HASHSIZE];
52 struct rt_entry old_hna[HASHSIZE];
55 +olsr_addroute_add_function(int (*function)(struct rt_entry*), olsr_u8_t type)
57 + struct export_route_entry *tmp;
58 + tmp = olsr_malloc(sizeof *tmp, "olsr_addroute_add_function");
60 + tmp->function = function;
61 + tmp->next = add_routes;
66 +olsr_delroute_add_function(int (*function) (struct rt_entry*), olsr_u8_t type)
68 + struct export_route_entry *tmp;
69 + tmp = olsr_malloc(sizeof *tmp, "olsr_delroute_add_function");
71 + tmp->function = function;
72 + tmp->next = del_routes;
78 +olsr_addroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
80 + struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */;
84 + if (function == tmp->function && type == tmp->type)
86 + if (tmp == add_routes)
88 + add_routes = add_routes->next;
94 + prev->next = tmp->next;
106 +olsr_delroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
108 + struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */;
112 + if (function == tmp->function && type == tmp->type)
114 + if (tmp == del_routes)
116 + del_routes = del_routes->next;
122 + prev->next = tmp->next;
134 +olsr_init_export_route()
136 + olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET);
137 + olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6);
138 + olsr_delroute_add_function(&olsr_ioctl_del_route, AF_INET);
139 + olsr_delroute_add_function(&olsr_ioctl_del_route6, AF_INET6);
143 +olsr_export_add_route (struct rt_entry *e)
146 + struct export_route_entry *tmp;
147 + for (tmp = add_routes; tmp; tmp = tmp->next)
149 + if (tmp->type == AF_INET)
150 + retval = tmp->function(e);
156 +olsr_export_add_route6 (struct rt_entry *e)
159 + struct export_route_entry *tmp;
160 + for (tmp = add_routes; tmp; tmp = tmp->next)
162 + if (tmp->type == AF_INET6)
163 + retval = tmp->function(e);
169 +olsr_export_del_route (struct rt_entry *e)
172 + struct export_route_entry *tmp;
173 + for (tmp = del_routes; tmp; tmp = tmp->next)
175 + if (tmp->type == AF_INET)
176 + retval = tmp->function(e);
182 +olsr_export_del_route6 (struct rt_entry *e)
185 + struct export_route_entry *tmp;
186 + for (tmp = del_routes; tmp; tmp = tmp->next)
188 + if (tmp->type == AF_INET6)
189 + retval = tmp->function(e);
197 olsr_init_old_table()
199 if(!olsr_cnf->host_emul)
201 if(olsr_cnf->ip_version == AF_INET)
202 - error = olsr_ioctl_del_route(destination_ptr->destination);
203 + error = olsr_export_del_route(destination_ptr->destination);
205 - error = olsr_ioctl_del_route6(destination_ptr->destination);
206 + error = olsr_export_del_route6(destination_ptr->destination);
211 if(!olsr_cnf->host_emul)
213 if(olsr_cnf->ip_version == AF_INET)
214 - error=olsr_ioctl_add_route(destination_kernel->destination);
215 + error=olsr_export_add_route(destination_kernel->destination);
217 - error=olsr_ioctl_add_route6(destination_kernel->destination);
218 + error=olsr_export_add_route6(destination_kernel->destination);
222 diff -Nur olsrd-0.4.10.orig/src/process_routes.h olsrd-0.4.10/src/process_routes.h
223 --- olsrd-0.4.10.orig/src/process_routes.h 2005-05-29 14:47:45.000000000 +0200
224 +++ olsrd-0.4.10/src/process_routes.h 2006-12-01 09:10:15.000000000 +0100
226 extern struct rt_entry old_routes[HASHSIZE];
227 extern struct rt_entry old_hna[HASHSIZE];
230 +olsr_init_export_route(void);
233 +olsr_addroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
236 +olsr_addroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
239 +olsr_delroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
242 +olsr_delroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
245 +olsr_export_add_route (struct rt_entry*);
248 +olsr_export_del_route (struct rt_entry*);
251 +olsr_export_add_route6 (struct rt_entry*);
254 +olsr_export_del_route6 (struct rt_entry*);
258 olsr_init_old_table(void);