remove the need for C99 math (closes: #1579)
[openwrt/svn-archive/archive.git] / net / olsrd / patches / 160-olsrd-quagga-routehandler.patch
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
4 @@ -280,6 +280,9 @@
5 /* Initialize parser */
6 olsr_init_parser();
7
8 + /* Initialize route-exporter */
9 + olsr_init_export_route();
10 +
11 /* Initialize message sequencnumber */
12 init_msg_seqno();
13
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
17 @@ -3,6 +3,9 @@
18 * Copyright (c) 2004, Andreas T√łnnesen(andreto@olsr.org)
19 * All rights reserved.
20 *
21 + * export_route_entry interface added by Immo 'FaUl Wehrenberg
22 + * <immo@chaostreff-dortmund.de>
23 + *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 @@ -39,7 +42,6 @@
28 * $Id: process_routes.c,v 1.27 2005/05/30 13:13:38 kattemat Exp $
29 */
30
31 -
32 #include "defs.h"
33 #include "olsr.h"
34 #include "log.h"
35 @@ -51,10 +53,162 @@
36 #define strerror(x) StrError(x)
37 #endif
38
39 +struct export_route_entry
40 +{
41 + olsr_u8_t type; /* AF_INET/AF_INET6 */
42 + int (*function)(struct rt_entry*);
43 + struct export_route_entry *next;
44 +};
45 +
46 +
47 +static struct export_route_entry *add_routes;
48 +static struct export_route_entry *del_routes;
49 +
50
51 struct rt_entry old_routes[HASHSIZE];
52 struct rt_entry old_hna[HASHSIZE];
53
54 +void
55 +olsr_addroute_add_function(int (*function)(struct rt_entry*), olsr_u8_t type)
56 +{
57 + struct export_route_entry *tmp;
58 + tmp = olsr_malloc(sizeof *tmp, "olsr_addroute_add_function");
59 + tmp->type = type;
60 + tmp->function = function;
61 + tmp->next = add_routes;
62 + add_routes = tmp;
63 +}
64 +
65 +void
66 +olsr_delroute_add_function(int (*function) (struct rt_entry*), olsr_u8_t type)
67 +{
68 + struct export_route_entry *tmp;
69 + tmp = olsr_malloc(sizeof *tmp, "olsr_delroute_add_function");
70 + tmp->type = type;
71 + tmp->function = function;
72 + tmp->next = del_routes;
73 + del_routes = tmp;
74 +}
75 +
76 +
77 +int
78 +olsr_addroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
79 +{
80 + struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */;
81 + tmp = add_routes;
82 + while (tmp)
83 + {
84 + if (function == tmp->function && type == tmp->type)
85 + {
86 + if (tmp == add_routes)
87 + {
88 + add_routes = add_routes->next;
89 + free (tmp);
90 + return 1;
91 + }
92 + else
93 + {
94 + prev->next = tmp->next;
95 + free (tmp);
96 + return 1;
97 + }
98 + }
99 + prev = tmp;
100 + tmp = tmp->next;
101 + }
102 + return 0;
103 +}
104 +
105 +int
106 +olsr_delroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
107 +{
108 + struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */;
109 + tmp = del_routes;
110 + while (tmp)
111 + {
112 + if (function == tmp->function && type == tmp->type)
113 + {
114 + if (tmp == del_routes)
115 + {
116 + del_routes = del_routes->next;
117 + free (tmp);
118 + return 1;
119 + }
120 + else
121 + {
122 + prev->next = tmp->next;
123 + free (tmp);
124 + return 1;
125 + }
126 + }
127 + prev = tmp;
128 + tmp = tmp->next;
129 + }
130 + return 0;
131 +}
132 +
133 +void
134 +olsr_init_export_route()
135 +{
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);
140 +}
141 +
142 +int
143 +olsr_export_add_route (struct rt_entry *e)
144 +{
145 + int retval = 0;
146 + struct export_route_entry *tmp;
147 + for (tmp = add_routes; tmp; tmp = tmp->next)
148 + {
149 + if (tmp->type == AF_INET)
150 + retval = tmp->function(e);
151 + }
152 + return retval;
153 +}
154 +
155 +int
156 +olsr_export_add_route6 (struct rt_entry *e)
157 +{
158 + int retval = 0;
159 + struct export_route_entry *tmp;
160 + for (tmp = add_routes; tmp; tmp = tmp->next)
161 + {
162 + if (tmp->type == AF_INET6)
163 + retval = tmp->function(e);
164 + }
165 + return retval;
166 +}
167 +
168 +int
169 +olsr_export_del_route (struct rt_entry *e)
170 +{
171 + int retval = 0;
172 + struct export_route_entry *tmp;
173 + for (tmp = del_routes; tmp; tmp = tmp->next)
174 + {
175 + if (tmp->type == AF_INET)
176 + retval = tmp->function(e);
177 + }
178 + return retval;
179 +}
180 +
181 +int
182 +olsr_export_del_route6 (struct rt_entry *e)
183 +{
184 + int retval = 0;
185 + struct export_route_entry *tmp;
186 + for (tmp = del_routes; tmp; tmp = tmp->next)
187 + {
188 + if (tmp->type == AF_INET6)
189 + retval = tmp->function(e);
190 + }
191 + return retval;
192 +}
193 +
194 +
195
196 int
197 olsr_init_old_table()
198 @@ -348,9 +502,9 @@
199 if(!olsr_cnf->host_emul)
200 {
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);
204 else
205 - error = olsr_ioctl_del_route6(destination_ptr->destination);
206 + error = olsr_export_del_route6(destination_ptr->destination);
207
208 if(error < 0)
209 {
210 @@ -436,9 +590,9 @@
211 if(!olsr_cnf->host_emul)
212 {
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);
216 else
217 - error=olsr_ioctl_add_route6(destination_kernel->destination);
218 + error=olsr_export_add_route6(destination_kernel->destination);
219
220 if(error < 0)
221 {
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
225 @@ -50,6 +50,34 @@
226 extern struct rt_entry old_routes[HASHSIZE];
227 extern struct rt_entry old_hna[HASHSIZE];
228
229 +void
230 +olsr_init_export_route(void);
231 +
232 +void
233 +olsr_addroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
234 +
235 +int
236 +olsr_addroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
237 +
238 +void
239 +olsr_delroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
240 +
241 +int
242 +olsr_delroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
243 +
244 +int
245 +olsr_export_add_route (struct rt_entry*);
246 +
247 +int
248 +olsr_export_del_route (struct rt_entry*);
249 +
250 +int
251 +olsr_export_add_route6 (struct rt_entry*);
252 +
253 +int
254 +olsr_export_del_route6 (struct rt_entry*);
255 +
256 +
257 int
258 olsr_init_old_table(void);
259