... | ... |
@@ -27,6 +27,72 @@ |
27 | 27 |
#include <mem/dmalloc.h> |
28 | 28 |
#endif |
29 | 29 |
|
30 |
+#ifdef DBG_MSG_QA |
|
31 |
+/* message quality assurance -- frequently, bugs in ser have |
|
32 |
+ been indicated by zero characters or long whitespaces |
|
33 |
+ in generated messages; this debugging option aborts if |
|
34 |
+ any such message is sighted |
|
35 |
+*/ |
|
36 |
+static int dbg_msg_qa(char *buf, int len) |
|
37 |
+{ |
|
38 |
+#define _DBG_WS_LEN 3 |
|
39 |
+#define _DBG_WS " " |
|
40 |
+ |
|
41 |
+ char *scan; |
|
42 |
+ int my_len; |
|
43 |
+ int space_cnt; |
|
44 |
+ enum { QA_ANY, QA_SPACE, QA_EOL1 } state; |
|
45 |
+ |
|
46 |
+ |
|
47 |
+ /* is there a zero character inthere ? */ |
|
48 |
+ if (memchr(buf, 0, len)) { |
|
49 |
+ LOG(L_CRIT, "BUG: message being sent with 0 in it\n"); |
|
50 |
+ return 0; |
|
51 |
+ } |
|
52 |
+ |
|
53 |
+ my_len=len; |
|
54 |
+ scan=buf; |
|
55 |
+ state=QA_ANY; |
|
56 |
+ space_cnt=0; |
|
57 |
+ |
|
58 |
+ while(my_len) { |
|
59 |
+ switch(*scan) { |
|
60 |
+ case ' ': if (state==QA_SPACE) { |
|
61 |
+ space_cnt++; |
|
62 |
+ if (space_cnt==4) { |
|
63 |
+ LOG(L_CRIT, "BUG(propably): DBG_MSG_QA: " |
|
64 |
+ "too many spaces\n"); |
|
65 |
+ return 0; |
|
66 |
+ } |
|
67 |
+ } else space_cnt=0; |
|
68 |
+ state=QA_SPACE; |
|
69 |
+ break; |
|
70 |
+ |
|
71 |
+ case '\r': /* ignore */ |
|
72 |
+ space_cnt=0; |
|
73 |
+ break; |
|
74 |
+ |
|
75 |
+ case '\n': /* don't proceed to body on EoH */ |
|
76 |
+ if (state==QA_EOL1) goto qa_passed; |
|
77 |
+ space_cnt=0; |
|
78 |
+ state=QA_EOL1; |
|
79 |
+ break; |
|
80 |
+ |
|
81 |
+ default: space_cnt=0; |
|
82 |
+ state=QA_ANY; |
|
83 |
+ break; |
|
84 |
+ } |
|
85 |
+ scan++; |
|
86 |
+ my_len--; |
|
87 |
+ } |
|
88 |
+ |
|
89 |
+ |
|
90 |
+qa_passed: |
|
91 |
+ return 1; |
|
92 |
+} |
|
93 |
+ |
|
94 |
+#endif |
|
95 |
+ |
|
30 | 96 |
|
31 | 97 |
int probe_max_receive_buffer( int udp_sock ) |
32 | 98 |
{ |
... | ... |
@@ -256,71 +322,6 @@ error: |
256 | 322 |
|
257 | 323 |
|
258 | 324 |
|
259 |
-#ifdef DBG_MSG_QA |
|
260 |
-/* message quality assurance -- frequently, bugs in ser have |
|
261 |
- been indicated by zero characters or long whitespaces |
|
262 |
- in generated messages; this debugging option aborts if |
|
263 |
- any such message is sighted |
|
264 |
-*/ |
|
265 |
-int dbg_msg_qa(char *buf, int len) |
|
266 |
-{ |
|
267 |
-#define _DBG_WS_LEN 3 |
|
268 |
-#define _DBG_WS " " |
|
269 |
- |
|
270 |
- char *scan; |
|
271 |
- int my_len; |
|
272 |
- int space_cnt; |
|
273 |
- enum { QA_ANY, QA_SPACE, QA_EOL1 } state; |
|
274 |
- |
|
275 |
- |
|
276 |
- /* is there a zero character inthere ? */ |
|
277 |
- if (memchr(buf, 0, len)) { |
|
278 |
- LOG(L_CRIT, "BUG: message being sent with 0 in it\n"); |
|
279 |
- return 0; |
|
280 |
- } |
|
281 |
- |
|
282 |
- my_len=len; |
|
283 |
- scan=buf; |
|
284 |
- state=QA_ANY; |
|
285 |
- space_cnt=0; |
|
286 |
- |
|
287 |
- while(my_len) { |
|
288 |
- switch(*scan) { |
|
289 |
- case ' ': if (state==QA_SPACE) { |
|
290 |
- space_cnt++; |
|
291 |
- if (space_cnt==4) { |
|
292 |
- LOG(L_CRIT, "BUG(propably): DBG_MSG_QA: " |
|
293 |
- "too many spaces\n"); |
|
294 |
- return 0; |
|
295 |
- } |
|
296 |
- } else space_cnt=0; |
|
297 |
- state=QA_SPACE; |
|
298 |
- break; |
|
299 |
- |
|
300 |
- case '\r': /* ignore */ |
|
301 |
- space_cnt=0; |
|
302 |
- break; |
|
303 |
- |
|
304 |
- case '\n': /* don't proceed to body on EoH */ |
|
305 |
- if (state==QA_EOL1) goto qa_passed; |
|
306 |
- space_cnt=0; |
|
307 |
- state=QA_EOL1; |
|
308 |
- break; |
|
309 |
- |
|
310 |
- default: space_cnt=0; |
|
311 |
- state=QA_ANY; |
|
312 |
- break; |
|
313 |
- } |
|
314 |
- scan++; |
|
315 |
- my_len--; |
|
316 |
- } |
|
317 |
- |
|
318 |
- |
|
319 |
-qa_passed: |
|
320 |
- return 1; |
|
321 |
-} |
|
322 |
- |
|
323 |
-#endif |
|
324 | 325 |
|
325 | 326 |
/* which socket to use? main socket or new one? */ |
326 | 327 |
int udp_send(struct socket_info *source, char *buf, unsigned len, union sockaddr_union* to) |