... | ... |
@@ -145,7 +145,7 @@ int udp_init(struct socket_info* sock_info) |
145 | 145 |
LOG(L_ERR, "ERROR: udp_init: setsockopt: %s\n", strerror(errno)); |
146 | 146 |
goto error; |
147 | 147 |
} |
148 |
-#ifdef __linux__ |
|
148 |
+#if defined (__linux__) && defined(UDP_ERRORS) |
|
149 | 149 |
optval=1; |
150 | 150 |
/* enable error receiving on unconnected sockets */ |
151 | 151 |
if(setsockopt(sock_info->socket, SOL_IP, IP_RECVERR, |
... | ... |
@@ -223,6 +223,17 @@ int udp_rcv_loop() |
223 | 223 |
} |
224 | 224 |
/*debugging, make print* msg work */ |
225 | 225 |
buf[len+1]=0; |
226 |
+ |
|
227 |
+#ifndef NO_ZERO_CHECKS |
|
228 |
+ if (len==0) { |
|
229 |
+ LOG(L_WARN, "WARNING: empty packet received\n"); |
|
230 |
+ continue; |
|
231 |
+ } |
|
232 |
+ if (buf[len-1]==0) { |
|
233 |
+ LOG(L_WARN, "WARNING: upstream bug - 0-terminated packet\n"); |
|
234 |
+ len--; |
|
235 |
+ } |
|
236 |
+#endif |
|
226 | 237 |
|
227 | 238 |
/* receive_msg must free buf too!*/ |
228 | 239 |
receive_msg(buf, len, from); |
... | ... |
@@ -242,19 +253,14 @@ error: |
242 | 253 |
|
243 | 254 |
|
244 | 255 |
|
245 |
-/* which socket to use? main socket or new one? */ |
|
246 |
-int udp_send(struct socket_info *source, char *buf, unsigned len, |
|
247 |
- union sockaddr_union* to, unsigned tolen) |
|
248 |
-{ |
|
249 |
- |
|
250 |
- int n; |
|
251 |
- |
|
256 |
+#ifdef DBG_MSG_QA |
|
252 | 257 |
/* message quality assurance -- frequently, bugs in ser have |
253 | 258 |
been indicated by zero characters or long whitespaces |
254 | 259 |
in generated messages; this debugging option aborts if |
255 | 260 |
any such message is sighted |
256 | 261 |
*/ |
257 |
-#ifdef DBG_MSG_QA |
|
262 |
+void dbg_msg_qa(char *buf, int len) |
|
263 |
+{ |
|
258 | 264 |
#define _DBG_WS_LEN 3 |
259 | 265 |
#define _DBG_WS " " |
260 | 266 |
|
... | ... |
@@ -308,9 +314,24 @@ int udp_send(struct socket_info *source, char *buf, unsigned len, |
308 | 314 |
|
309 | 315 |
|
310 | 316 |
qa_passed: |
317 |
+ return; |
|
318 |
+} |
|
311 | 319 |
|
312 | 320 |
#endif |
313 | 321 |
|
322 |
+/* which socket to use? main socket or new one? */ |
|
323 |
+int udp_send(struct socket_info *source, char *buf, unsigned len, |
|
324 |
+ union sockaddr_union* to, unsigned tolen) |
|
325 |
+{ |
|
326 |
+ |
|
327 |
+ int n; |
|
328 |
+ |
|
329 |
+#ifdef DBG_MSG_QA |
|
330 |
+ /* aborts on error, does nothing otherwise */ |
|
331 |
+ dbg_msg_qa( buf, len ); |
|
332 |
+#endif |
|
333 |
+ |
|
334 |
+ |
|
314 | 335 |
again: |
315 | 336 |
n=sendto(source->socket, buf, len, 0, &to->s, tolen); |
316 | 337 |
#ifdef XL_DEBUG |