... | ... |
@@ -40,7 +40,7 @@ export makefile_defs |
40 | 40 |
VERSION = 0 |
41 | 41 |
PATCHLEVEL = 8 |
42 | 42 |
SUBLEVEL = 12 |
43 |
-EXTRAVERSION = dev-t06 |
|
43 |
+EXTRAVERSION = dev-t07 |
|
44 | 44 |
|
45 | 45 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
46 | 46 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -272,7 +272,9 @@ DEFS+= $(extra_defs) \ |
272 | 272 |
-DUSE_IPV6 \ |
273 | 273 |
-DUSE_TCP \ |
274 | 274 |
-DDISABLE_NAGLE \ |
275 |
- -DDBG_QM_MALLOC \ |
|
275 |
+ -DF_MALLOC \ |
|
276 |
+ # -DDBG_F_MALLOC \ |
|
277 |
+ # -DDBG_QM_MALLOC \ |
|
276 | 278 |
#-DF_MALLOC \ |
277 | 279 |
#-DNO_DEBUG \ |
278 | 280 |
#-DNO_LOG |
... | ... |
@@ -3,7 +3,7 @@ $Id$ |
3 | 3 |
( - todo, x - done) |
4 | 4 |
|
5 | 5 |
release: |
6 |
-- fix kill(0, SIGTERM) on startup error (will kill also the launching shell |
|
6 |
+x fix kill(0, SIGTERM) on startup error (will kill also the launching shell |
|
7 | 7 |
if non-interactive) |
8 | 8 |
- fix modules destroy (some modules will try to free uninitialized resources |
9 | 9 |
if modules_init was not called first) |
... | ... |
@@ -93,24 +93,29 @@ error: |
93 | 93 |
|
94 | 94 |
|
95 | 95 |
|
96 |
-void print_ip(struct ip_addr* ip) |
|
96 |
+void print_ip(char* p, struct ip_addr* ip, char *s) |
|
97 | 97 |
{ |
98 | 98 |
switch(ip->af){ |
99 | 99 |
case AF_INET: |
100 |
- DBG("%d.%d.%d.%d", ip->u.addr[0], |
|
100 |
+ DBG("%s%d.%d.%d.%d%s", (p)?p:"", |
|
101 |
+ ip->u.addr[0], |
|
101 | 102 |
ip->u.addr[1], |
102 | 103 |
ip->u.addr[2], |
103 |
- ip->u.addr[3]); |
|
104 |
+ ip->u.addr[3], |
|
105 |
+ (s)?s:"" |
|
106 |
+ ); |
|
104 | 107 |
break; |
105 | 108 |
case AF_INET6: |
106 |
- DBG("%x:%x:%x:%x:%x:%x:%x:%x", htons(ip->u.addr16[0]), |
|
109 |
+ DBG("%s%x:%x:%x:%x:%x:%x:%x:%x%s", (p)?p:"", |
|
110 |
+ htons(ip->u.addr16[0]), |
|
107 | 111 |
htons(ip->u.addr16[1]), |
108 | 112 |
htons(ip->u.addr16[2]), |
109 | 113 |
htons(ip->u.addr16[3]), |
110 | 114 |
htons(ip->u.addr16[4]), |
111 | 115 |
htons(ip->u.addr16[5]), |
112 | 116 |
htons(ip->u.addr16[6]), |
113 |
- htons(ip->u.addr16[7]) |
|
117 |
+ htons(ip->u.addr16[7]), |
|
118 |
+ (s)?s:"" |
|
114 | 119 |
); |
115 | 120 |
break; |
116 | 121 |
default: |
... | ... |
@@ -153,5 +158,5 @@ void print_net(struct net* net) |
153 | 158 |
LOG(L_WARN, "ERROR: print net: null pointer\n"); |
154 | 159 |
return; |
155 | 160 |
} |
156 |
- print_ip(&net->ip); DBG("/"); print_ip(&net->mask); |
|
161 |
+ print_ip("", &net->ip, "/"); print_ip("", &net->mask, ""); |
|
157 | 162 |
} |
... | ... |
@@ -157,7 +157,7 @@ struct dest_info{ |
157 | 157 |
struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask); |
158 | 158 |
struct net* mk_net_bitlen(struct ip_addr* ip, unsigned int bitlen); |
159 | 159 |
|
160 |
-void print_ip(struct ip_addr* ip); |
|
160 |
+void print_ip(char* prefix, struct ip_addr* ip, char* suffix); |
|
161 | 161 |
void stdout_print_ip(struct ip_addr* ip); |
162 | 162 |
void print_net(struct net* net); |
163 | 163 |
|
... | ... |
@@ -24,11 +24,18 @@ |
24 | 24 |
* along with this program; if not, write to the Free Software |
25 | 25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
26 | 26 |
*/ |
27 |
+/* |
|
28 |
+ * History: |
|
29 |
+ * -------- |
|
30 |
+ * created by andrei |
|
31 |
+ * 2003-07-06 added fm_realloc (andrei) |
|
32 |
+ */ |
|
27 | 33 |
|
28 | 34 |
|
29 | 35 |
#if !defined(q_malloc) && !(defined VQ_MALLOC) && (defined F_MALLOC) |
30 | 36 |
|
31 | 37 |
#include <string.h> |
38 |
+#include <stdlib.h> |
|
32 | 39 |
|
33 | 40 |
#include "f_malloc.h" |
34 | 41 |
#include "../dprint.h" |
... | ... |
@@ -107,7 +114,42 @@ static inline void fm_insert_free(struct fm_block* qm, struct fm_frag* frag) |
107 | 114 |
|
108 | 115 |
|
109 | 116 |
|
110 |
-/* init malloc and return a qm_block*/ |
|
117 |
+ /* size should be already rounded-up */ |
|
118 |
+static inline |
|
119 |
+#ifdef DBG_F_MALLOC |
|
120 |
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size, |
|
121 |
+ char* file, char* func, unsigned int line) |
|
122 |
+#else |
|
123 |
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size) |
|
124 |
+#endif |
|
125 |
+{ |
|
126 |
+ unsigned int rest; |
|
127 |
+ struct fm_frag* n; |
|
128 |
+ |
|
129 |
+ rest=frag->size-size; |
|
130 |
+ if (rest>(FRAG_OVERHEAD+MIN_FRAG_SIZE)){ |
|
131 |
+ frag->size=size; |
|
132 |
+ /*split the fragment*/ |
|
133 |
+ n=FRAG_NEXT(frag); |
|
134 |
+ n->size=rest-FRAG_OVERHEAD; |
|
135 |
+#ifdef DBG_F_MALLOC |
|
136 |
+ qm->real_used+=FRAG_OVERHEAD; |
|
137 |
+ /* frag created by malloc, mark it*/ |
|
138 |
+ n->file=file; |
|
139 |
+ n->func="frag. from fm_malloc"; |
|
140 |
+ n->line=line; |
|
141 |
+ n->check=ST_CHECK_PATTERN; |
|
142 |
+#endif |
|
143 |
+ /* reinsert n in free list*/ |
|
144 |
+ fm_insert_free(qm, n); |
|
145 |
+ }else{ |
|
146 |
+ /* we cannot split this fragment any more => alloc all of it*/ |
|
147 |
+ } |
|
148 |
+} |
|
149 |
+ |
|
150 |
+ |
|
151 |
+ |
|
152 |
+/* init malloc and return a fm_block*/ |
|
111 | 153 |
struct fm_block* fm_malloc_init(char* address, unsigned int size) |
112 | 154 |
{ |
113 | 155 |
char* start; |
... | ... |
@@ -170,12 +212,10 @@ void* fm_malloc(struct fm_block* qm, unsigned int size) |
170 | 212 |
{ |
171 | 213 |
struct fm_frag** f; |
172 | 214 |
struct fm_frag* frag; |
173 |
- struct fm_frag* n; |
|
174 |
- unsigned int rest; |
|
175 | 215 |
int hash; |
176 | 216 |
|
177 | 217 |
#ifdef DBG_F_MALLOC |
178 |
- DBG("fm_malloc(%x, %d) called from %s: %s(%d)\n", qm, size, file, func, |
|
218 |
+ DBG("fm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func, |
|
179 | 219 |
line); |
180 | 220 |
#endif |
181 | 221 |
/*size must be a multiple of 8*/ |
... | ... |
@@ -199,28 +239,12 @@ found: |
199 | 239 |
/* detach it from the free list*/ |
200 | 240 |
frag=*f; |
201 | 241 |
*f=frag->u.nxt_free; |
242 |
+ frag->u.nxt_free=0; /* mark it as 'taken' */ |
|
202 | 243 |
|
203 | 244 |
/*see if we'll use full frag, or we'll split it in 2*/ |
204 |
- rest=frag->size-size; |
|
205 |
- if (rest>(FRAG_OVERHEAD+MIN_FRAG_SIZE)){ |
|
206 |
- frag->size=size; |
|
207 |
- /*split the fragment*/ |
|
208 |
- n=FRAG_NEXT(frag); |
|
209 |
- n->size=rest-FRAG_OVERHEAD; |
|
210 |
-#ifdef DBG_F_MALLOC |
|
211 |
- qm->real_used+=FRAG_OVERHEAD; |
|
212 |
- /* frag created by malloc, mark it*/ |
|
213 |
- n->file=file; |
|
214 |
- n->func="frag. from qm_malloc"; |
|
215 |
- n->line=line; |
|
216 |
- n->check=ST_CHECK_PATTERN; |
|
217 |
-#endif |
|
218 |
- /* reinsert n in free list*/ |
|
219 |
- fm_insert_free(qm, n); |
|
220 |
- }else{ |
|
221 |
- /* we cannot split this fragment any more => alloc all of it*/ |
|
222 |
- } |
|
245 |
+ |
|
223 | 246 |
#ifdef DBG_F_MALLOC |
247 |
+ fm_split_frag(qm, frag, size, file, func, line); |
|
224 | 248 |
qm->real_used+=frag->size; |
225 | 249 |
qm->used+=frag->size; |
226 | 250 |
|
... | ... |
@@ -231,8 +255,10 @@ found: |
231 | 255 |
frag->func=func; |
232 | 256 |
frag->line=line; |
233 | 257 |
frag->check=ST_CHECK_PATTERN; |
234 |
- DBG("fm_malloc(%x, %d) returns address %x \n", qm, size, |
|
258 |
+ DBG("fm_malloc(%p, %d) returns address %p \n", qm, size, |
|
235 | 259 |
(char*)frag+sizeof(struct fm_frag)); |
260 |
+#else |
|
261 |
+ fm_split_frag(qm, frag, size); |
|
236 | 262 |
#endif |
237 | 263 |
return (char*)frag+sizeof(struct fm_frag); |
238 | 264 |
} |
... | ... |
@@ -250,9 +276,9 @@ void fm_free(struct fm_block* qm, void* p) |
250 | 276 |
unsigned int size; |
251 | 277 |
|
252 | 278 |
#ifdef DBG_F_MALLOC |
253 |
- DBG("fm_free(%x, %x), called from %s: %s(%d)\n", qm, p, file, func, line); |
|
279 |
+ DBG("fm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line); |
|
254 | 280 |
if (p>(void*)qm->last_frag || p<(void*)qm->first_frag){ |
255 |
- LOG(L_CRIT, "BUG: fm_free: bad pointer %x (out of memory block!) - " |
|
281 |
+ LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - " |
|
256 | 282 |
"aborting\n", p); |
257 | 283 |
abort(); |
258 | 284 |
} |
... | ... |
@@ -263,7 +289,7 @@ void fm_free(struct fm_block* qm, void* p) |
263 | 289 |
} |
264 | 290 |
f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag)); |
265 | 291 |
#ifdef DBG_F_MALLOC |
266 |
- DBG("fm_free: freeing block alloc'ed from %s: %s(%d)\n", f->file, f->func, |
|
292 |
+ DBG("fm_free: freeing block alloc'ed from %s: %s(%ld)\n", f->file, f->func, |
|
267 | 293 |
f->line); |
268 | 294 |
#endif |
269 | 295 |
size=f->size; |
... | ... |
@@ -279,6 +305,131 @@ void fm_free(struct fm_block* qm, void* p) |
279 | 305 |
} |
280 | 306 |
|
281 | 307 |
|
308 |
+#ifdef DBG_F_MALLOC |
|
309 |
+void* fm_realloc(struct fm_block* qm, void* p, unsigned int size, |
|
310 |
+ char* file, char* func, unsigned int line) |
|
311 |
+#else |
|
312 |
+void* fm_realloc(struct fm_block* qm, void* p, unsigned int size) |
|
313 |
+#endif |
|
314 |
+{ |
|
315 |
+ struct fm_frag *f; |
|
316 |
+ struct fm_frag **pf; |
|
317 |
+ unsigned int diff; |
|
318 |
+ unsigned int orig_size; |
|
319 |
+ struct fm_frag *n; |
|
320 |
+ void *ptr; |
|
321 |
+ |
|
322 |
+#ifdef DBG_F_MALLOC |
|
323 |
+ DBG("fm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size, |
|
324 |
+ file, func, line); |
|
325 |
+ if (p>(void*)qm->last_frag || p<(void*)qm->first_frag){ |
|
326 |
+ LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - " |
|
327 |
+ "aborting\n", p); |
|
328 |
+ abort(); |
|
329 |
+ } |
|
330 |
+#endif |
|
331 |
+ if (size==0) { |
|
332 |
+ if (p) |
|
333 |
+#ifdef DBG_F_MALLOC |
|
334 |
+ fm_free(qm, p, file, func, line); |
|
335 |
+#else |
|
336 |
+ fm_free(qm, p); |
|
337 |
+#endif |
|
338 |
+ return 0; |
|
339 |
+ } |
|
340 |
+ if (p==0) |
|
341 |
+#ifdef DBG_F_MALLOC |
|
342 |
+ return fm_malloc(qm, size, file, func, line); |
|
343 |
+#else |
|
344 |
+ return fm_malloc(qm, size); |
|
345 |
+#endif |
|
346 |
+ f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag)); |
|
347 |
+#ifdef DBG_F_MALLOC |
|
348 |
+ DBG("fm_realloc: realloc'ing frag %p alloc'ed from %s: %s(%ld)\n", |
|
349 |
+ f, f->file, f->func, f->line); |
|
350 |
+#endif |
|
351 |
+ size=ROUNDUP(size); |
|
352 |
+ orig_size=f->size; |
|
353 |
+ if (f->size > size){ |
|
354 |
+ /* shrink */ |
|
355 |
+#ifdef DBG_F_MALLOC |
|
356 |
+ DBG("fm_realloc: shrinking from %ld to %d\n", f->size, size); |
|
357 |
+ fm_split_frag(qm, f, size, file, "frag. from fm_realloc", line); |
|
358 |
+ qm->real_used-=(orig_size-f->size); |
|
359 |
+ qm->used-=(orig_size-f->size); |
|
360 |
+#else |
|
361 |
+ fm_split_frag(qm, f, size); |
|
362 |
+#endif |
|
363 |
+ }else if (f->size<size){ |
|
364 |
+ /* grow */ |
|
365 |
+#ifdef DBG_F_MALLOC |
|
366 |
+ DBG("fm_realloc: growing from %ld to %d\n", f->size, size); |
|
367 |
+#endif |
|
368 |
+ diff=size-f->size; |
|
369 |
+ n=FRAG_NEXT(f); |
|
370 |
+ if (((char*)n < (char*)qm->last_frag) && |
|
371 |
+ (n->u.nxt_free)&&((n->size+FRAG_OVERHEAD)>=diff)){ |
|
372 |
+ /* join */ |
|
373 |
+ /* detach n from the free list */ |
|
374 |
+ pf=&(qm->free_hash[GET_HASH(n->size)]); |
|
375 |
+ /* find it */ |
|
376 |
+ for(;(*pf)&&(*pf!=n); pf=&((*pf)->u.nxt_free)); |
|
377 |
+ if (*pf==0){ |
|
378 |
+ /* not found, bad! */ |
|
379 |
+ LOG(L_CRIT, "BUG: fm_realloc: could not find %p in free " |
|
380 |
+ "list (hash=%ld)\n", n, GET_HASH(n->size)); |
|
381 |
+ abort(); |
|
382 |
+ } |
|
383 |
+ /* detach */ |
|
384 |
+ *pf=n->u.nxt_free; |
|
385 |
+ /* join */ |
|
386 |
+ f->size+=n->size+FRAG_OVERHEAD; |
|
387 |
+ #ifdef DBG_F_MALLOC |
|
388 |
+ qm->real_used-=FRAG_OVERHEAD; |
|
389 |
+ #endif |
|
390 |
+ /* split it if necessary */ |
|
391 |
+ if (f->size > size){ |
|
392 |
+ #ifdef DBG_F_MALLOC |
|
393 |
+ fm_split_frag(qm, f, size, file, "fragm. from fm_realloc", |
|
394 |
+ line); |
|
395 |
+ #else |
|
396 |
+ fm_split_frag(qm, f, size); |
|
397 |
+ #endif |
|
398 |
+ } |
|
399 |
+ #ifdef DBG_F_MALLOC |
|
400 |
+ qm->real_used+=(f->size-orig_size); |
|
401 |
+ qm->used+=(f->size-orig_size); |
|
402 |
+ #endif |
|
403 |
+ }else{ |
|
404 |
+ /* could not join => realloc */ |
|
405 |
+ #ifdef DBG_F_MALLOC |
|
406 |
+ ptr=fm_malloc(qm, size, file, func, line); |
|
407 |
+ #else |
|
408 |
+ ptr=fm_malloc(qm, size); |
|
409 |
+ #endif |
|
410 |
+ if (ptr) |
|
411 |
+ /* copy, need by libssl */ |
|
412 |
+ memcpy(ptr, p, orig_size); |
|
413 |
+ #ifdef DBG_F_MALLOC |
|
414 |
+ fm_free(qm, p, file, func, line); |
|
415 |
+ #else |
|
416 |
+ fm_free(qm, p); |
|
417 |
+ #endif |
|
418 |
+ p=ptr; |
|
419 |
+ } |
|
420 |
+ }else{ |
|
421 |
+ /* do nothing */ |
|
422 |
+#ifdef DBG_F_MALLOC |
|
423 |
+ DBG("fm_realloc: doing nothing, same size: %ld - %d\n", f->size, size); |
|
424 |
+#endif |
|
425 |
+ } |
|
426 |
+#ifdef DBG_F_MALLOC |
|
427 |
+ DBG("fm_realloc: returning %p\n", p); |
|
428 |
+#endif |
|
429 |
+ return p; |
|
430 |
+} |
|
431 |
+ |
|
432 |
+ |
|
282 | 433 |
|
283 | 434 |
void fm_status(struct fm_block* qm) |
284 | 435 |
{ |
... | ... |
@@ -118,6 +118,13 @@ void fm_free(struct fm_block*, void* p, char* file, char* func, |
118 | 118 |
void fm_free(struct fm_block*, void* p); |
119 | 119 |
#endif |
120 | 120 |
|
121 |
+#ifdef DBG_F_MALLOC |
|
122 |
+void* fm_realloc(struct fm_block*, void* p, unsigned int size, |
|
123 |
+ char* file, char* func, unsigned int line); |
|
124 |
+#else |
|
125 |
+void* fm_realloc(struct fm_block*, void* p, unsigned int size); |
|
126 |
+#endif |
|
127 |
+ |
|
121 | 128 |
void fm_status(struct fm_block*); |
122 | 129 |
|
123 | 130 |
|
... | ... |
@@ -42,6 +42,17 @@ |
42 | 42 |
#include "../config.h" |
43 | 43 |
#include "../dprint.h" |
44 | 44 |
|
45 |
+/* fix debug defines, DBG_F_MALLOC <=> DBG_QM_MALLOC */ |
|
46 |
+#ifdef F_MALLOC |
|
47 |
+ #ifdef DBG_F_MALLOC |
|
48 |
+ #ifndef DBG_QM_MALLOC |
|
49 |
+ #define DBG_QM_MALLOC |
|
50 |
+ #endif |
|
51 |
+ #elif defined(DBG_QM_MALLOC) |
|
52 |
+ #define DBG_F_MALLOC |
|
53 |
+ #endif |
|
54 |
+#endif |
|
55 |
+ |
|
45 | 56 |
#ifdef PKG_MALLOC |
46 | 57 |
# ifdef VQ_MALLOC |
47 | 58 |
# include "vq_malloc.h" |
... | ... |
@@ -66,11 +77,14 @@ |
66 | 77 |
__FUNCTION__, __LINE__) |
67 | 78 |
# define pkg_free(p) vqm_free(mem_block, (p), __FILE__, \ |
68 | 79 |
__FUNCTION__, __LINE__) |
80 |
+# warn "no proper realloc implementation, use another mem. alloc" |
|
69 | 81 |
# elif defined F_MALLOC |
70 | 82 |
# define pkg_malloc(s) fm_malloc(mem_block, (s),__FILE__, \ |
71 | 83 |
__FUNCTION__, __LINE__) |
72 | 84 |
# define pkg_free(p) fm_free(mem_block, (p), __FILE__, \ |
73 | 85 |
__FUNCTION__, __LINE__) |
86 |
+# define pkg_realloc(p, s) fm_realloc(mem_block, (p), (s),__FILE__, \ |
|
87 |
+ __FUNCTION__, __LINE__) |
|
74 | 88 |
# else |
75 | 89 |
# define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, \ |
76 | 90 |
__FUNCTION__, __LINE__) |
... | ... |
@@ -85,6 +99,7 @@ |
85 | 99 |
# define pkg_free(p) vqm_free(mem_block, (p)) |
86 | 100 |
# elif defined F_MALLOC |
87 | 101 |
# define pkg_malloc(s) fm_malloc(mem_block, (s)) |
102 |
+# define pkg_realloc(p, s) fm_realloc(mem_block, (p), (s)) |
|
88 | 103 |
# define pkg_free(p) fm_free(mem_block, (p)) |
89 | 104 |
# else |
90 | 105 |
# define pkg_malloc(s) qm_malloc(mem_block, (s)) |
... | ... |
@@ -268,7 +268,7 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm, |
268 | 268 |
|
269 | 269 |
|
270 | 270 |
/* returns 0 on success, -1 on error; |
271 |
- * new_size < size & rounduped already!*/ |
|
271 |
+ * new_size < size & rounded-up already!*/ |
|
272 | 272 |
static inline |
273 | 273 |
#ifdef DBG_QM_MALLOC |
274 | 274 |
int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size, |
... | ... |
@@ -64,11 +64,13 @@ |
64 | 64 |
# define MY_FREE vqm_free |
65 | 65 |
# define MY_STATUS vqm_status |
66 | 66 |
# define shm_malloc_init vqm_malloc_init |
67 |
+# warn "no proper vq_realloc implementantion, try another memory allocator" |
|
67 | 68 |
#elif defined F_MALLOC |
68 | 69 |
# include "f_malloc.h" |
69 | 70 |
extern struct fm_block* shm_block; |
70 | 71 |
# define MY_MALLOC fm_malloc |
71 | 72 |
# define MY_FREE fm_free |
73 |
+# define MY_REALLOC fm_realloc |
|
72 | 74 |
# define MY_STATUS fm_status |
73 | 75 |
# define shm_malloc_init fm_malloc_init |
74 | 76 |
#else |
... | ... |
@@ -96,6 +98,18 @@ void shm_mem_destroy(); |
96 | 98 |
#define shm_lock() lock_get(mem_lock) |
97 | 99 |
#define shm_unlock() lock_release(mem_lock) |
98 | 100 |
|
101 |
+/* fix DBG MALLOC stuff */ |
|
102 |
+ |
|
103 |
+/* fix debug defines, DBG_F_MALLOC <=> DBG_QM_MALLOC */ |
|
104 |
+#ifdef F_MALLOC |
|
105 |
+ #ifdef DBG_F_MALLOC |
|
106 |
+ #ifndef DBG_QM_MALLOC |
|
107 |
+ #define DBG_QM_MALLOC |
|
108 |
+ #endif |
|
109 |
+ #elif defined(DBG_QM_MALLOC) |
|
110 |
+ #define DBG_F_MALLOC |
|
111 |
+ #endif |
|
112 |
+#endif |
|
99 | 113 |
|
100 | 114 |
|
101 | 115 |
#ifdef DBG_QM_MALLOC |
... | ... |
@@ -370,9 +370,8 @@ inline static int comp_ip(struct ip_addr* ip, void* param, int op, int subtype) |
370 | 370 |
* !!??!! review: remove this? */ |
371 | 371 |
he=rev_resolvehost(ip); |
372 | 372 |
if (he==0){ |
373 |
- DBG( "comp_ip: could not rev_resolve ip address: "); |
|
374 |
- print_ip(ip); |
|
375 |
- DBG("\n"); |
|
373 |
+ print_ip( "comp_ip: could not rev_resolve ip address: ", |
|
374 |
+ ip, "\n"); |
|
376 | 375 |
ret=0; |
377 | 376 |
}else{ |
378 | 377 |
/* compare with primary host name */ |
... | ... |
@@ -184,7 +184,7 @@ void print_expr(struct expr* exp) |
184 | 184 |
print_net((struct net*)exp->r.param); |
185 | 185 |
break; |
186 | 186 |
case IP_ST: |
187 |
- print_ip((struct ip_addr*)exp->r.param); |
|
187 |
+ print_ip("", (struct ip_addr*)exp->r.param, ""); |
|
188 | 188 |
break; |
189 | 189 |
case ACTIONS_ST: |
190 | 190 |
print_action((struct action*)exp->r.param); |
... | ... |
@@ -328,7 +328,7 @@ void print_action(struct action* a) |
328 | 328 |
DBG("%lu",t->p1.number); |
329 | 329 |
break; |
330 | 330 |
case IP_ST: |
331 |
- print_ip((struct ip_addr*)t->p1.data); |
|
331 |
+ print_ip("", (struct ip_addr*)t->p1.data, ""); |
|
332 | 332 |
break; |
333 | 333 |
case EXPR_ST: |
334 | 334 |
print_expr((struct expr*)t->p1.data); |
... | ... |
@@ -147,6 +147,8 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su, |
147 | 147 |
c->rcv.dst_ip=ba->address; |
148 | 148 |
c->rcv.dst_port=ba->port_no; |
149 | 149 |
} |
150 |
+ print_ip("tcpconn_new: new tcp connection: ", &c->rcv.src_ip, "\n"); |
|
151 |
+ DBG( "tcpconn_new: on port %d, type %d\n", c->rcv.src_port, type); |
|
150 | 152 |
init_tcp_req(&c->req); |
151 | 153 |
c->id=connection_id++; |
152 | 154 |
c->rcv.proto_reserved1=0; /* this will be filled before receive_message*/ |
... | ... |
@@ -313,15 +315,15 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port) |
313 | 315 |
unsigned hash; |
314 | 316 |
|
315 | 317 |
#ifdef EXTRA_DEBUG |
316 |
- DBG("tcpconn_find: %d ",id ); print_ip(ip); DBG(" %d\n", port); |
|
318 |
+ DBG("tcpconn_find: %d port %d\n",id, port); |
|
319 |
+ print_ip("tcpconn_find: ip ", ip, "\n"); |
|
317 | 320 |
#endif |
318 | 321 |
if (id){ |
319 | 322 |
hash=tcp_id_hash(id); |
320 | 323 |
for (c=tcpconn_id_hash[hash]; c; c=c->id_next){ |
321 | 324 |
#ifdef EXTRA_DEBUG |
322 |
- DBG("c=%p, c->id=%d, ip=",c, c->id); |
|
323 |
- print_ip(&c->rcv.src_ip); |
|
324 |
- DBG(" port=%d\n", c->rcv.src_port); |
|
325 |
+ DBG("c=%p, c->id=%d, port=%d\n",c, c->id, c->rcv.src_port); |
|
326 |
+ print_ip("ip=", &c->rcv.src_ip, "\n"); |
|
325 | 327 |
#endif |
326 | 328 |
if ((id==c->id)&&(c->state!=S_CONN_BAD)) return c; |
327 | 329 |
} |
... | ... |
@@ -329,9 +331,8 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port) |
329 | 331 |
hash=tcp_addr_hash(ip, port); |
330 | 332 |
for (c=tcpconn_addr_hash[hash]; c; c=c->next){ |
331 | 333 |
#ifdef EXTRA_DEBUG |
332 |
- DBG("c=%p, c->id=%d, ip=",c, c->id); |
|
333 |
- print_ip(&c->rcv.src_ip); |
|
334 |
- DBG(" port=%d\n", c->rcv.src_port); |
|
334 |
+ DBG("c=%p, c->id=%d, port=%d\n",c, c->id, c->rcv.src_port); |
|
335 |
+ print_ip("ip=",&c->rcv.src_ip,"\n"); |
|
335 | 336 |
#endif |
336 | 337 |
if ( (c->state!=S_CONN_BAD) && (port==c->rcv.src_port) && |
337 | 338 |
(ip_addr_cmp(ip, &c->rcv.src_ip)) ) |
... | ... |
@@ -450,16 +450,16 @@ again: |
450 | 450 |
"buf:\n%.*s\nparsed:\n%.*s\n", req->state, req->error, |
451 | 451 |
(int)(req->pos-req->buf), req->buf, |
452 | 452 |
(int)(req->parsed-req->start), req->start); |
453 |
- DBG("- received from: port %d, ip -", con->rcv.src_port); |
|
454 |
- print_ip(&con->rcv.src_ip); DBG("-\n"); |
|
453 |
+ DBG("- received from: port %d\n", con->rcv.src_port); |
|
454 |
+ print_ip("- received from: ip ",&con->rcv.src_ip, "\n"); |
|
455 | 455 |
resp=CONN_ERROR; |
456 | 456 |
goto end_req; |
457 | 457 |
} |
458 | 458 |
if (req->complete){ |
459 | 459 |
#ifdef EXTRA_DEBUG |
460 | 460 |
DBG("tcp_read_req: end of header part\n"); |
461 |
- DBG("- received from: port %d, ip - ", con->rcv.src_port); |
|
462 |
- print_ip(&con->rcv.src_ip); DBG("-\n"); |
|
461 |
+ DBG("- received from: port %d\n", con->rcv.src_port); |
|
462 |
+ print_ip("- received from: ip ", &con->rcv.src_ip, "\n"); |
|
463 | 463 |
DBG("tcp_read_req: headers:\n%.*s.\n", |
464 | 464 |
(int)(req->body-req->start), req->start); |
465 | 465 |
#endif |