remove the need for C99 math (closes: #1579)
[openwrt/svn-archive/archive.git] / net / olsrd / patches / 230-olsrd-fixes-backport.patch
1 diff -Nur olsrd-0.4.10.orig/lib/dot_draw/src/olsrd_dot_draw.c olsrd-0.4.10/lib/dot_draw/src/olsrd_dot_draw.c
2 --- olsrd-0.4.10.orig/lib/dot_draw/src/olsrd_dot_draw.c 2005-12-30 03:23:59.000000000 +0100
3 +++ olsrd-0.4.10/lib/dot_draw/src/olsrd_dot_draw.c 2006-12-01 20:23:37.000000000 +0100
4 @@ -136,6 +136,8 @@
5 /* Register the "ProcessChanges" function */
6 register_pcf(&pcf_event);
7
8 + plugin_ipc_init();
9 +
10 return 1;
11 }
12
13 @@ -237,6 +239,7 @@
14
15
16 /* Register with olsrd */
17 + printf("Adding socket with olsrd\n");
18 add_olsr_socket(ipc_socket, &ipc_action);
19 ipc_socket_up = 1;
20 }
21 diff -Nur olsrd-0.4.10.orig/lib/httpinfo/src/olsrd_httpinfo.c olsrd-0.4.10/lib/httpinfo/src/olsrd_httpinfo.c
22 --- olsrd-0.4.10.orig/lib/httpinfo/src/olsrd_httpinfo.c 2006-12-01 20:20:31.000000000 +0100
23 +++ olsrd-0.4.10/lib/httpinfo/src/olsrd_httpinfo.c 2006-12-01 20:23:37.000000000 +0100
24 @@ -297,6 +297,7 @@
25 if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) == -1)
26 {
27 olsr_printf(1, "(HTTPINFO) bind failed %s\n", strerror(errno));
28 + close(s);
29 return -1;
30 }
31
32 @@ -304,6 +305,7 @@
33 if (listen(s, 1) == -1)
34 {
35 olsr_printf(1, "(HTTPINFO) listen failed %s\n", strerror(errno));
36 + close(s);
37 return -1;
38 }
39
40 diff -Nur olsrd-0.4.10.orig/lib/secure/src/olsrd_secure.c olsrd-0.4.10/lib/secure/src/olsrd_secure.c
41 --- olsrd-0.4.10.orig/lib/secure/src/olsrd_secure.c 2005-11-19 09:37:23.000000000 +0100
42 +++ olsrd-0.4.10/lib/secure/src/olsrd_secure.c 2006-12-01 20:23:37.000000000 +0100
43 @@ -952,7 +952,7 @@
44 else
45 {
46 /* Check configuration timeout */
47 - if(!TIMED_OUT(&entry->conftime))
48 + if(!TIMED_OUT(entry->conftime))
49 {
50 /* If registered - do not accept! */
51 olsr_printf(1, "[ENC]Challenge from registered node...dropping!\n");
52 @@ -1205,7 +1205,7 @@
53 while(tmp_list != &timestamps[index])
54 {
55 /*Check if the entry is timed out*/
56 - if((TIMED_OUT(&tmp_list->valtime)) && (TIMED_OUT(&tmp_list->conftime)))
57 + if((TIMED_OUT(tmp_list->valtime)) && (TIMED_OUT(tmp_list->conftime)))
58 {
59 entry_to_delete = tmp_list;
60 tmp_list = tmp_list->next;
61 diff -Nur olsrd-0.4.10.orig/make/Makefile.linux olsrd-0.4.10/make/Makefile.linux
62 --- olsrd-0.4.10.orig/make/Makefile.linux 2005-11-19 09:43:51.000000000 +0100
63 +++ olsrd-0.4.10/make/Makefile.linux 2006-12-01 20:23:37.000000000 +0100
64 @@ -3,7 +3,11 @@
65 #
66
67 INSTALL_PREFIX ?=
68 +ifeq ($(shell arch),x86_64)
69 +LIBDIR = $(INSTALL_PREFIX)/usr/lib64
70 +else
71 LIBDIR = $(INSTALL_PREFIX)/usr/lib
72 +endif
73
74 SRCS += $(wildcard src/linux/*.c) $(wildcard src/unix/*.c)
75 HDRS += $(wildcard src/linux/*.h) $(wildcard src/unix/*.h)
76 diff -Nur olsrd-0.4.10.orig/make/Makefile.osx olsrd-0.4.10/make/Makefile.osx
77 --- olsrd-0.4.10.orig/make/Makefile.osx 2005-12-29 20:48:43.000000000 +0100
78 +++ olsrd-0.4.10/make/Makefile.osx 2006-12-01 20:23:37.000000000 +0100
79 @@ -2,6 +2,10 @@
80 # MAC OSX SPECIFIC CONFIGURATION
81 #
82
83 +# don't strip executables and bundles for now until we figure out the proper way
84 +# to do it (flags).
85 +STRIP = \#
86 +
87 INSTALL_PREFIX ?=
88 LIBDIR = $(INSTALL_PREFIX)/usr/lib
89
90 @@ -12,12 +16,10 @@
91 LIBS =
92
93 PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
94 -INSTALL_LIB = install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
95 - /sbin/ldconfig
96 +INSTALL_LIB = install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME)
97
98 ifdef OLSRD_PLUGIN
99 -CFLAGS += -fPIC
100 -LDFLAGS = -fPIC -dynamiclib -single_module -flat_namespace -undefined suppress
101 +LDFLAGS = -bundle -flat_namespace -undefined suppress
102 else
103 LDFLAGS = -dynamic
104 endif
105 diff -Nur olsrd-0.4.10.orig/Makefile olsrd-0.4.10/Makefile
106 --- olsrd-0.4.10.orig/Makefile 2006-12-01 20:20:31.000000000 +0100
107 +++ olsrd-0.4.10/Makefile 2006-12-01 20:23:37.000000000 +0100
108 @@ -171,3 +171,4 @@
109
110 build_all: cfgparser olsrd libs
111 install_all: install install_libs
112 +clean_all: uberclean clean_libs
113 diff -Nur olsrd-0.4.10.orig/src/bsd/net.c olsrd-0.4.10/src/bsd/net.c
114 --- olsrd-0.4.10.orig/src/bsd/net.c 2005-08-28 21:30:29.000000000 +0200
115 +++ olsrd-0.4.10/src/bsd/net.c 2006-12-01 20:23:37.000000000 +0100
116 @@ -290,6 +290,7 @@
117 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
118 {
119 perror("SO_REUSEADDR failed");
120 + close(sock);
121 return (-1);
122 }
123 /* connect to PORT on HOST */
124 @@ -298,6 +299,7 @@
125 printf("FAILED\n");
126 fprintf(stderr, "Error connecting %d - %s\n", errno, strerror(errno));
127 printf("connection refused\n");
128 + close(sock);
129 return (-1);
130 }
131
132 @@ -332,6 +334,7 @@
133 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
134 {
135 perror("SO_REUSEADDR failed");
136 + close(sock);
137 return (-1);
138 }
139
140 @@ -339,12 +342,14 @@
141 if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0)
142 {
143 perror("SO_REUSEPORT failed");
144 + close(sock);
145 return (-1);
146 }
147
148 if (setsockopt(sock, IPPROTO_IP, IP_RECVIF, &on, sizeof(on)) < 0)
149 {
150 perror("IP_RECVIF failed");
151 + close(sock);
152 return (-1);
153 }
154 #endif /* SPOOF */
155 @@ -403,6 +408,7 @@
156 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
157 {
158 perror("SO_REUSEADDR failed");
159 + close(sock);
160 return (-1);
161 }
162
163 diff -Nur olsrd-0.4.10.orig/src/linux/net.c olsrd-0.4.10/src/linux/net.c
164 --- olsrd-0.4.10.orig/src/linux/net.c 2005-09-17 22:48:50.000000000 +0200
165 +++ olsrd-0.4.10/src/linux/net.c 2006-12-01 20:23:37.000000000 +0100
166 @@ -434,6 +434,7 @@
167 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
168 {
169 perror("SO_REUSEADDR failed");
170 + close(sock);
171 return (-1);
172 }
173 /* connect to PORT on HOST */
174 @@ -442,6 +443,7 @@
175 printf("FAILED\n");
176 fprintf(stderr, "Error connecting %d - %s\n", errno, strerror(errno));
177 printf("connection refused\n");
178 + close(sock);
179 return (-1);
180 }
181
182 @@ -487,6 +489,7 @@
183 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
184 {
185 perror("SO_REUSEADDR failed");
186 + close(sock);
187 return (-1);
188 }
189
190 @@ -520,6 +523,7 @@
191 {
192 fprintf(stderr, "Could not bind socket to device... exiting!\n\n");
193 syslog(LOG_ERR, "Could not bind socket to device... exiting!\n\n");
194 + close(sock);
195 return -1;
196 }
197
198 @@ -606,6 +610,7 @@
199 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
200 {
201 perror("SO_REUSEADDR failed");
202 + close(sock);
203 return (-1);
204 }
205
206 @@ -619,6 +624,7 @@
207 {
208 fprintf(stderr, "Could not bind socket to device... exiting!\n\n");
209 syslog(LOG_ERR, "Could not bind socket to device... exiting!\n\n");
210 + close(sock);
211 return -1;
212 }
213
214 diff -Nur olsrd-0.4.10.orig/src/main.c olsrd-0.4.10/src/main.c
215 --- olsrd-0.4.10.orig/src/main.c 2006-12-01 20:20:31.000000000 +0100
216 +++ olsrd-0.4.10/src/main.c 2006-12-01 20:23:54.000000000 +0100
217 @@ -118,7 +118,7 @@
218 system_tick_divider = 1000/sysconf(_SC_CLK_TCK);
219
220 /* Check if user is root */
221 - if(getuid() || getgid())
222 + if(geteuid())
223 {
224 fprintf(stderr, "You must be root(uid = 0) to run olsrd!\nExiting\n\n");
225 exit(EXIT_FAILURE);
226 @@ -395,6 +395,7 @@
227 signal(SIGHUP, olsr_reconfigure);
228 signal(SIGINT, olsr_shutdown);
229 signal(SIGTERM, olsr_shutdown);
230 + signal(SIGPIPE, SIG_IGN);
231 #endif
232
233 /* Register socket poll event */
234 @@ -535,6 +536,7 @@
235 fprintf(stderr, " [-hint <hello interval (secs)>] [-tcint <tc interval (secs)>]\n");
236 fprintf(stderr, " [-midint <mid interval (secs)>] [-hnaint <hna interval (secs)>]\n");
237 fprintf(stderr, " [-T <Polling Rate (secs)>] [-nofork] [-hemu <ip_address>] \n");
238 + fprintf(stderr, " [-lql <LQ level>] [-lqw <LQ winsize>]\n");
239
240 }
241
242 @@ -635,6 +637,42 @@
243 memcpy(&ifcnf->ipv4_broadcast.v4, &in.s_addr, sizeof(olsr_u32_t));
244 continue;
245 }
246 +
247 + /*
248 + * Set LQ level
249 + */
250 + if (strcmp(*argv, "-lql") == 0)
251 + {
252 + int tmp_lq_level;
253 + NEXT_ARG;
254 + CHECK_ARGC;
255 +
256 + /* Sanity checking is done later */
257 + sscanf(*argv, "%d", &tmp_lq_level);
258 + olsr_cnf->lq_level = tmp_lq_level;
259 + continue;
260 + }
261 +
262 + /*
263 + * Set LQ winsize
264 + */
265 + if (strcmp(*argv, "-lqw") == 0)
266 + {
267 + int tmp_lq_wsize;
268 + NEXT_ARG;
269 + CHECK_ARGC;
270 +
271 + sscanf(*argv, "%d", &tmp_lq_wsize);
272 +
273 + if(tmp_lq_wsize < MIN_LQ_WSIZE || tmp_lq_wsize > MAX_LQ_WSIZE)
274 + {
275 + printf("LQ winsize %d not allowed. Range [%d-%d]\n",
276 + tmp_lq_wsize, MIN_LQ_WSIZE, MAX_LQ_WSIZE);
277 + olsr_exit(__func__, EXIT_FAILURE);
278 + }
279 + olsr_cnf->lq_wsize = tmp_lq_wsize;
280 + continue;
281 + }
282
283 /*
284 * Enable additional debugging information to be logged.
285 diff -Nur olsrd-0.4.10.orig/src/scheduler.c olsrd-0.4.10/src/scheduler.c
286 --- olsrd-0.4.10.orig/src/scheduler.c 2006-12-01 20:20:31.000000000 +0100
287 +++ olsrd-0.4.10/src/scheduler.c 2006-12-01 20:23:37.000000000 +0100
288 @@ -330,6 +330,7 @@
289 {
290 prev->next = entry->next;
291 }
292 + free(entry);
293 return 1;
294 }
295
296 diff -Nur olsrd-0.4.10.orig/src/win32/net.c olsrd-0.4.10/src/win32/net.c
297 --- olsrd-0.4.10.orig/src/win32/net.c 2005-05-30 15:50:27.000000000 +0200
298 +++ olsrd-0.4.10/src/win32/net.c 2006-12-01 20:23:37.000000000 +0100
299 @@ -87,6 +87,7 @@
300 printf("FAILED\n");
301 fprintf(stderr, "Error connecting %d - %s\n", errno, strerror(errno));
302 printf("connection refused\n");
303 + closesocket(sock);
304 return (-1);
305 }
306