... | ... |
@@ -171,7 +171,7 @@ ifeq ($(ARCH), i386) |
171 | 171 |
ifeq ($(CC_NAME), gcc) |
172 | 172 |
#common stuff |
173 | 173 |
CFLAGS=-O9 -funroll-loops -Wcast-align $(PROFILE) -Winline\ |
174 |
- #-Wmissing-prototypes \ |
|
174 |
+ -Wall #-Wmissing-prototypes \ |
|
175 | 175 |
#if gcc 3.0 |
176 | 176 |
ifeq ($(CC_SHORTVER), 3.0) |
177 | 177 |
CFLAGS+=-minline-all-stringops -malign-double \ |
... | ... |
@@ -23,6 +23,7 @@ |
23 | 23 |
#include <stdlib.h> |
24 | 24 |
#include <netinet/in.h> |
25 | 25 |
#include <arpa/inet.h> |
26 |
+#include <string.h> |
|
26 | 27 |
|
27 | 28 |
#ifdef DEBUG_DMALLOC |
28 | 29 |
#include <dmalloc.h> |
... | ... |
@@ -77,7 +78,7 @@ int do_action(struct action* a, struct sip_msg* msg) |
77 | 77 |
if (err){ |
78 | 78 |
LOG(L_ERR, "ERROR: do_action: " |
79 | 79 |
"forward: bad port in " |
80 |
- "uri: <%s>\n", uri.port); |
|
80 |
+ "uri: <%s>\n", uri.port.s); |
|
81 | 81 |
ret=E_UNSPEC; |
82 | 82 |
goto error_fwd_uri; |
83 | 83 |
} |
... | ... |
@@ -369,7 +370,7 @@ int do_action(struct action* a, struct sip_msg* msg) |
369 | 369 |
default: |
370 | 370 |
LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type); |
371 | 371 |
} |
372 |
-skip: |
|
372 |
+/*skip:*/ |
|
373 | 373 |
return ret; |
374 | 374 |
|
375 | 375 |
error_uri: |
... | ... |
@@ -389,7 +390,7 @@ error_fwd_uri: |
389 | 389 |
int run_actions(struct action* a, struct sip_msg* msg) |
390 | 390 |
{ |
391 | 391 |
struct action* t; |
392 |
- int ret; |
|
392 |
+ int ret=E_UNSPEC; |
|
393 | 393 |
static int rec_lev=0; |
394 | 394 |
struct sr_module *mod; |
395 | 395 |
|
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
|
2 |
- |
|
2 |
+#include <string.h> |
|
3 | 3 |
#include "dprint.h" |
4 | 4 |
#include "mem/mem.h" |
5 | 5 |
#include "data_lump_rpl.h" |
... | ... |
@@ -36,7 +36,7 @@ error: |
36 | 36 |
|
37 | 37 |
|
38 | 38 |
|
39 |
-int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
39 |
+void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
40 | 40 |
{ |
41 | 41 |
struct lump_rpl *foo; |
42 | 42 |
|
... | ... |
@@ -51,7 +51,7 @@ int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
51 | 51 |
|
52 | 52 |
|
53 | 53 |
|
54 |
-int free_lump_rpl(struct lump_rpl* lump) |
|
54 |
+void free_lump_rpl(struct lump_rpl* lump) |
|
55 | 55 |
{ |
56 | 56 |
if (lump && lump->text.s) pkg_free(lump->text.s); |
57 | 57 |
if (lump) pkg_free(lump); |
... | ... |
@@ -17,8 +17,8 @@ struct lump_rpl |
17 | 17 |
|
18 | 18 |
struct lump_rpl* build_lump_rpl( char* , int ); |
19 | 19 |
|
20 |
-int add_lump_rpl(struct sip_msg * , struct lump_rpl* ); |
|
20 |
+void add_lump_rpl(struct sip_msg * , struct lump_rpl* ); |
|
21 | 21 |
|
22 |
-int free_lump_rpl(struct lump_rpl* ); |
|
22 |
+void free_lump_rpl(struct lump_rpl* ); |
|
23 | 23 |
|
24 | 24 |
#endif |
... | ... |
@@ -82,12 +82,12 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p) |
82 | 82 |
} |
83 | 83 |
/* sent requests stats */ |
84 | 84 |
else STATS_TX_REQUEST( msg->first_line.u.request.method_value ); |
85 |
- free(buf); |
|
85 |
+ pkg_free(buf); |
|
86 | 86 |
free(to); |
87 | 87 |
/* received_buf & line_buf will be freed in receiv_msg by free_lump_list*/ |
88 | 88 |
return 0; |
89 | 89 |
error: |
90 |
- if (buf) free(buf); |
|
90 |
+ if (buf) pkg_free(buf); |
|
91 | 91 |
if (to) free(to); |
92 | 92 |
return -1; |
93 | 93 |
} |
... | ... |
@@ -131,12 +131,7 @@ int forward_reply(struct sip_msg* msg) |
131 | 131 |
struct sockaddr_in* to; |
132 | 132 |
unsigned int new_len; |
133 | 133 |
struct sr_module *mod; |
134 |
-#ifdef DNS_IP_HACK |
|
135 |
- int err; |
|
136 |
-#endif |
|
137 |
- |
|
138 |
- |
|
139 |
- |
|
134 |
+ |
|
140 | 135 |
to=0; |
141 | 136 |
new_buf=0; |
142 | 137 |
/*check if first via host = us */ |
... | ... |
@@ -145,7 +140,7 @@ int forward_reply(struct sip_msg* msg) |
145 | 145 |
if(strcmp(msg->via1->host.s, names[r])==0) break; |
146 | 146 |
if (r==addresses_no){ |
147 | 147 |
LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me :" |
148 |
- " %s\n", msg->via1->host); |
|
148 |
+ " %s\n", msg->via1->host.s); |
|
149 | 149 |
/* send error msg back? */ |
150 | 150 |
goto error; |
151 | 151 |
} |
... | ... |
@@ -198,12 +193,12 @@ int forward_reply(struct sip_msg* msg) |
198 | 198 |
DBG(" reply forwarded to %s:%d\n",msg->via2->host.s, |
199 | 199 |
(unsigned short) msg->via2->port); |
200 | 200 |
|
201 |
- free(new_buf); |
|
201 |
+ pkg_free(new_buf); |
|
202 | 202 |
free(to); |
203 | 203 |
skip: |
204 | 204 |
return 0; |
205 | 205 |
error: |
206 |
- if (new_buf) free(new_buf); |
|
206 |
+ if (new_buf) pkg_free(new_buf); |
|
207 | 207 |
if (to) free(to); |
208 | 208 |
return -1; |
209 | 209 |
} |
... | ... |
@@ -591,8 +591,8 @@ int main(int argc, char** argv) |
591 | 591 |
printf("flags: %s\n", flags ); |
592 | 592 |
print_ct_constants(); |
593 | 593 |
printf("%s\n",id); |
594 |
- printf("%s compiled on %s at %s with %s\n", __FILE__, |
|
595 |
- __DATE__, __TIME__, COMPILER ); |
|
594 |
+ printf("%s compiled on %s with %s\n", __FILE__, |
|
595 |
+ compiled, COMPILER ); |
|
596 | 596 |
|
597 | 597 |
exit(0); |
598 | 598 |
break; |
... | ... |
@@ -23,9 +23,11 @@ These notices must be retained in any copies of any part of this |
23 | 23 |
documentation and/or software. |
24 | 24 |
*/ |
25 | 25 |
|
26 |
+#include <string.h> |
|
26 | 27 |
#include "md5global.h" |
27 | 28 |
#include "md5.h" |
28 | 29 |
|
30 |
+ |
|
29 | 31 |
#define USE_MEM |
30 | 32 |
|
31 | 33 |
/* Constants for MD5Transform routine. |
... | ... |
@@ -4,6 +4,8 @@ |
4 | 4 |
|
5 | 5 |
#if !defined(q_malloc) && !(defined VQ_MALLOC) |
6 | 6 |
|
7 |
+#include <string.h> |
|
8 |
+ |
|
7 | 9 |
#include "f_malloc.h" |
8 | 10 |
#include "../dprint.h" |
9 | 11 |
|
... | ... |
@@ -87,7 +89,6 @@ struct fm_block* fm_malloc_init(char* address, unsigned int size) |
87 | 87 |
char* end; |
88 | 88 |
struct fm_block* qm; |
89 | 89 |
unsigned int init_overhead; |
90 |
- int h; |
|
91 | 90 |
|
92 | 91 |
/* make address and size multiple of 8*/ |
93 | 92 |
start=(char*)ROUNDUP((unsigned int) address); |
... | ... |
@@ -261,7 +262,7 @@ void fm_status(struct fm_block* qm) |
261 | 261 |
int h; |
262 | 262 |
int size; |
263 | 263 |
|
264 |
- LOG(L_INFO, "fm_status (%x):\n", qm); |
|
264 |
+ LOG(L_INFO, "fm_status (%p):\n", qm); |
|
265 | 265 |
if (!qm) return; |
266 | 266 |
|
267 | 267 |
LOG(L_INFO, " heap size= %d\n", qm->size); |
... | ... |
@@ -7,11 +7,15 @@ |
7 | 7 |
#include "mem.h" |
8 | 8 |
|
9 | 9 |
#ifdef PKG_MALLOC |
10 |
-# ifdef VQ_MALLOC |
|
11 |
-# include "vq_malloc.h" |
|
12 |
-# else |
|
13 |
-# include "q_malloc.h" |
|
14 |
-# endif |
|
10 |
+ #ifdef VQ_MALLOC |
|
11 |
+ #include "vq_malloc.h" |
|
12 |
+ #else |
|
13 |
+ #include "q_malloc.h" |
|
14 |
+ #endif |
|
15 |
+#endif |
|
16 |
+ |
|
17 |
+#ifdef SHM_MEM |
|
18 |
+#include "shm_mem.h" |
|
15 | 19 |
#endif |
16 | 20 |
|
17 | 21 |
#ifdef PKG_MALLOC |
... | ... |
@@ -82,7 +82,7 @@ void* _shm_resize( void* p, unsigned int s, char* file, char* func, unsigned int |
82 | 82 |
void* _shm_resize( void* p , unsigned int s) |
83 | 83 |
#endif |
84 | 84 |
{ |
85 |
- char *c; |
|
85 |
+ |
|
86 | 86 |
#ifdef VQ_MALLOC |
87 | 87 |
struct vqm_frag *f; |
88 | 88 |
#else |
... | ... |
@@ -125,13 +125,14 @@ void* _shm_resize( void* p , unsigned int s) |
125 | 125 |
int shm_mem_init() |
126 | 126 |
{ |
127 | 127 |
|
128 |
+#ifndef FAST_LOCK |
|
128 | 129 |
union semun su; |
130 |
+#endif |
|
129 | 131 |
#ifdef SHM_MMAP |
130 | 132 |
int fd; |
131 | 133 |
#else |
132 | 134 |
struct shmid_ds shm_info; |
133 | 135 |
#endif |
134 |
- int ret; |
|
135 | 136 |
|
136 | 137 |
#ifdef SHM_MMAP |
137 | 138 |
if (shm_mempool && (shm_mempool!=(void*)-1)){ |
... | ... |
@@ -112,7 +112,7 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param , |
112 | 112 |
T->outbound_request[branch] = rb; |
113 | 113 |
SEND_BUFFER( rb ); |
114 | 114 |
/* link the retransmission buffer to our structures when the job is done */ |
115 |
- free( buf ) ; buf=NULL; |
|
115 |
+ pkg_free( buf ) ; buf=NULL; |
|
116 | 116 |
|
117 | 117 |
DBG("DEBUG: t_forward_nonack: starting timers (retrans and FR) %d\n",get_ticks() ); |
118 | 118 |
/*sets and starts the FINAL RESPONSE timer */ |
... | ... |
@@ -154,7 +154,7 @@ error: |
154 | 154 |
shm_free(rb); |
155 | 155 |
T->outbound_request[branch]=NULL; |
156 | 156 |
} |
157 |
- if (buf) free( buf ); |
|
157 |
+ if (buf) pkg_free( buf ); |
|
158 | 158 |
|
159 | 159 |
return -1; |
160 | 160 |
|
... | ... |
@@ -222,7 +222,7 @@ int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param , |
222 | 222 |
shm_unlock(); |
223 | 223 |
|
224 | 224 |
memcpy( (char *) srb + sizeof ( struct retrans_buff ), buf, len ); |
225 |
- free( buf ); |
|
225 |
+ pkg_free( buf ); |
|
226 | 226 |
|
227 | 227 |
relay_ack( T, branch, srb, len ); |
228 | 228 |
return 1; |
... | ... |
@@ -106,7 +106,7 @@ int t_send_reply( struct sip_msg* p_msg , unsigned int code , char * text ) |
106 | 106 |
|
107 | 107 |
SEND_PR_BUFFER( rb, buf, len ); |
108 | 108 |
|
109 |
- free( buf ) ; |
|
109 |
+ pkg_free( buf ) ; |
|
110 | 110 |
/* start/stops the proper timers*/ |
111 | 111 |
|
112 | 112 |
DBG("DEBUG: t_send_reply: finished\n"); |
... | ... |
@@ -114,7 +114,7 @@ int t_send_reply( struct sip_msg* p_msg , unsigned int code , char * text ) |
114 | 114 |
return 1; |
115 | 115 |
|
116 | 116 |
error2: |
117 |
- free ( buf ); |
|
117 |
+ pkg_free ( buf ); |
|
118 | 118 |
error: |
119 | 119 |
return -1; |
120 | 120 |
} |
... | ... |
@@ -385,7 +385,7 @@ cleanup: |
385 | 385 |
error2: |
386 | 386 |
if (start_fr) |
387 | 387 |
set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST ); |
388 |
- if (buf) free( buf ); |
|
388 |
+ if (buf) pkg_free( buf ); |
|
389 | 389 |
error1: |
390 | 390 |
if (!save_clone) sip_msg_free( clone ); |
391 | 391 |
error: |
... | ... |
@@ -174,9 +174,10 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl) |
174 | 174 |
error: |
175 | 175 |
LOG(L_INFO, "ERROR:parse_first_line: bad %s first line\n", |
176 | 176 |
(fl->type==SIP_REPLY)?"reply(status)":"request"); |
177 |
+ LOG(L_INFO, "ERROR: at line 0 char %d\n", offset); |
|
177 | 178 |
error1: |
178 | 179 |
fl->type=SIP_INVALID; |
179 |
- LOG(L_INFO, "ERROR: at line 0 char %d\n", offset); |
|
180 |
+ LOG(L_INFO, "ERROR:parse_first_line: bad message\n"); |
|
180 | 181 |
/* skip line */ |
181 | 182 |
nl=eat_line(buffer,len); |
182 | 183 |
return nl; |
... | ... |
@@ -677,7 +678,7 @@ error: |
677 | 677 |
int parse_msg(char* buf, unsigned int len, struct sip_msg* msg) |
678 | 678 |
{ |
679 | 679 |
|
680 |
- char *tmp, *bar; |
|
680 |
+ char *tmp; |
|
681 | 681 |
char* rest; |
682 | 682 |
char* first_via; |
683 | 683 |
char* second_via; |
... | ... |
@@ -717,6 +718,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg) |
717 | 717 |
break; |
718 | 718 |
default: |
719 | 719 |
DBG("unknown type %d\n",fl->type); |
720 |
+ goto error; |
|
720 | 721 |
} |
721 | 722 |
msg->unparsed=tmp; |
722 | 723 |
/*find first Via: */ |
... | ... |
@@ -4,6 +4,8 @@ |
4 | 4 |
|
5 | 5 |
|
6 | 6 |
#include <sys/socket.h> |
7 |
+#include <netdb.h> |
|
8 |
+#include <string.h> |
|
7 | 9 |
|
8 | 10 |
#include "msg_translator.h" |
9 | 11 |
#include "mem/mem.h" |
... | ... |
@@ -11,13 +13,16 @@ |
11 | 11 |
#include "config.h" |
12 | 12 |
#include "md5utils.h" |
13 | 13 |
#include "data_lump_rpl.h" |
14 |
-#include <netdb.h> |
|
15 | 14 |
|
16 | 15 |
|
17 | 16 |
|
18 | 17 |
#define MAX_VIA_LINE_SIZE 240 |
19 | 18 |
#define MAX_RECEIVED_SIZE 57 |
20 | 19 |
|
20 |
+/* mallocs for local stuff (not needed to be shared mem?)*/ |
|
21 |
+#define local_malloc pkg_malloc |
|
22 |
+#define local_free pkg_free |
|
23 |
+ |
|
21 | 24 |
|
22 | 25 |
#define append_str(_dest,_src,_len,_msg) \ |
23 | 26 |
do{\ |
... | ... |
@@ -114,7 +119,6 @@ int check_address(unsigned long ip, char *name, int resolver) |
114 | 114 |
} |
115 | 115 |
if (resolver&DO_REV_DNS){ |
116 | 116 |
DBG("check_address: doing rev. dns lookup\n"); |
117 |
- print_ip(ip); |
|
118 | 117 |
/* try reverse dns */ |
119 | 118 |
he=gethostbyaddr((char*)&ip, sizeof(ip), AF_INET); |
120 | 119 |
if (he && (strcmp(he->h_name, name)==0)) |
... | ... |
@@ -232,6 +236,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
232 | 232 |
struct lump *t,*r; |
233 | 233 |
struct lump* anchor; |
234 | 234 |
|
235 |
+ uri_len=0; |
|
235 | 236 |
orig=msg->orig; |
236 | 237 |
buf=msg->buf; |
237 | 238 |
len=msg->len; |
... | ... |
@@ -332,7 +337,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
332 | 332 |
s_offset=t->u.offset; |
333 | 333 |
/* do nothing */ |
334 | 334 |
break; |
335 |
- debug: |
|
335 |
+ default: |
|
336 | 336 |
LOG(L_CRIT,"BUG:build_req_buf_from_sip_req: invalid" |
337 | 337 |
" op for data lump (%x)\n", r->op); |
338 | 338 |
} |
... | ... |
@@ -354,7 +359,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
354 | 354 |
uri_len=msg->new_uri.len; |
355 | 355 |
new_len=new_len-msg->first_line.u.request.uri.len+uri_len; |
356 | 356 |
} |
357 |
- new_buf=(char*)malloc(new_len+1); |
|
357 |
+ new_buf=(char*)local_malloc(new_len+1); |
|
358 | 358 |
if (new_buf==0){ |
359 | 359 |
LOG(L_ERR, "ERROR: build_req_buf_from_sip_req: out of memory\n"); |
360 | 360 |
goto error; |
... | ... |
@@ -477,7 +482,7 @@ error1: |
477 | 477 |
if (received_buf) pkg_free(received_buf); |
478 | 478 |
if (line_buf) pkg_free(line_buf); |
479 | 479 |
error: |
480 |
- if (new_buf) free(new_buf); |
|
480 |
+ if (new_buf) local_free(new_buf); |
|
481 | 481 |
*returned_len=0; |
482 | 482 |
return 0; |
483 | 483 |
} |
... | ... |
@@ -488,10 +493,9 @@ error: |
488 | 488 |
char * build_res_buf_from_sip_res( struct sip_msg* msg, |
489 | 489 |
unsigned int *returned_len) |
490 | 490 |
{ |
491 |
- unsigned int new_len, via_len,r; |
|
491 |
+ unsigned int new_len, via_len; |
|
492 | 492 |
char* new_buf; |
493 | 493 |
unsigned offset, s_offset, size; |
494 |
- struct hostent* he; |
|
495 | 494 |
char* orig; |
496 | 495 |
char* buf; |
497 | 496 |
unsigned int len; |
... | ... |
@@ -516,7 +520,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg, |
516 | 516 |
new_len=len-via_len; |
517 | 517 |
|
518 | 518 |
DBG(" old size: %d, new size: %d\n", len, new_len); |
519 |
- new_buf=(char*)malloc(new_len+1);/* +1 is for debugging |
|
519 |
+ new_buf=(char*)local_malloc(new_len+1);/* +1 is for debugging |
|
520 | 520 |
(\0 to print it )*/ |
521 | 521 |
if (new_buf==0){ |
522 | 522 |
LOG(L_ERR, "ERROR: build_res_buf_from_sip_res: out of memory\n"); |
... | ... |
@@ -535,7 +539,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg, |
535 | 535 |
*returned_len=new_len; |
536 | 536 |
return new_buf; |
537 | 537 |
error: |
538 |
- if (new_buf) free(new_buf); |
|
538 |
+ if (new_buf) local_free(new_buf); |
|
539 | 539 |
*returned_len=0; |
540 | 540 |
return 0; |
541 | 541 |
} |
... | ... |
@@ -596,7 +600,7 @@ char * build_res_buf_from_sip_req( unsigned int code , |
596 | 596 |
len += CRLF_LEN; /*new line*/ |
597 | 597 |
/*allocating mem*/ |
598 | 598 |
buf = 0; |
599 |
- buf = (char*) malloc( len+1 ); |
|
599 |
+ buf = (char*) local_malloc( len+1 ); |
|
600 | 600 |
if (!buf) |
601 | 601 |
{ |
602 | 602 |
LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: out of memory " |
... | ... |
@@ -677,7 +681,7 @@ char * build_res_buf_from_sip_req( unsigned int code , |
677 | 677 |
*returned_len = len; |
678 | 678 |
return buf; |
679 | 679 |
error: |
680 |
- if (buf) free(buf); |
|
680 |
+ if (buf) local_free(buf); |
|
681 | 681 |
*returned_len=0; |
682 | 682 |
return 0; |
683 | 683 |
} |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
|
2 | 2 |
|
3 | 3 |
#include <stdlib.h> |
4 |
+#include <string.h> |
|
4 | 5 |
#include "dprint.h" |
5 | 6 |
#include "msg_parser.h" |
6 | 7 |
#include "ut.h" |
... | ... |
@@ -35,11 +36,15 @@ enum{ S_PARA_NAME=20, PARA_NAME, S_EQUAL, S_PARA_VALUE, TAG1, TAG2, TAG3 |
35 | 35 |
char* parse_to_param(char *buffer, char *end, struct to_body *to_b, |
36 | 36 |
int *returned_status) |
37 | 37 |
{ |
38 |
- struct to_param *param=0; |
|
39 |
- int status =PARA_START; |
|
38 |
+ struct to_param *param; |
|
39 |
+ int status; |
|
40 | 40 |
int saved_status; |
41 | 41 |
char *tmp; |
42 | 42 |
|
43 |
+ param=0; |
|
44 |
+ status=PARA_START; |
|
45 |
+ saved_status=PARA_START; |
|
46 |
+ |
|
43 | 47 |
for( tmp=buffer; tmp<end; tmp++) |
44 | 48 |
{ |
45 | 49 |
switch(*tmp) |
... | ... |
@@ -389,11 +394,13 @@ error: |
389 | 389 |
|
390 | 390 |
char* parse_to(char* buffer, char *end, struct to_body *to_b) |
391 | 391 |
{ |
392 |
- struct to_param *param=0; |
|
393 |
- int status = START_TO; |
|
392 |
+ int status; |
|
394 | 393 |
int saved_status; |
395 | 394 |
char *tmp,*foo; |
396 | 395 |
|
396 |
+ status=START_TO; |
|
397 |
+ foo=0; |
|
398 |
+ |
|
397 | 399 |
for( tmp=buffer; tmp<end; tmp++) |
398 | 400 |
{ |
399 | 401 |
switch(*tmp) |
... | ... |
@@ -18,6 +18,7 @@ |
18 | 18 |
|
19 | 19 |
|
20 | 20 |
#include <stdlib.h> |
21 |
+#include <string.h> |
|
21 | 22 |
#include "dprint.h" |
22 | 23 |
#include "msg_parser.h" |
23 | 24 |
#include "ut.h" |
... | ... |
@@ -208,7 +209,7 @@ char* parse_via_param( char* p, char* end, int* pstate, |
208 | 208 |
case F_PARAM: |
209 | 209 |
case FIN_HIDDEN: |
210 | 210 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in" |
211 |
- " state %d\n"); |
|
211 |
+ " state %d\n", *tmp, state); |
|
212 | 212 |
goto error; |
213 | 213 |
case F_CR: |
214 | 214 |
case F_LF: |
... | ... |
@@ -237,7 +238,7 @@ char* parse_via_param( char* p, char* end, int* pstate, |
237 | 237 |
case FIN_TTL: |
238 | 238 |
case FIN_RECEIVED: |
239 | 239 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in" |
240 |
- " state %d\n"); |
|
240 |
+ " state %d\n", *tmp, state); |
|
241 | 241 |
goto error; |
242 | 242 |
case F_CR: |
243 | 243 |
case F_LF: |
... | ... |
@@ -585,7 +586,7 @@ goto error; |
585 | 585 |
|
586 | 586 |
find_value: |
587 | 587 |
tmp++; |
588 |
- for(tmp;*tmp;tmp++){ |
|
588 |
+ for(;*tmp;tmp++){ |
|
589 | 589 |
switch(*tmp){ |
590 | 590 |
case ' ': |
591 | 591 |
case '\t': |
... | ... |
@@ -607,7 +608,7 @@ find_value: |
607 | 607 |
break; |
608 | 608 |
default: |
609 | 609 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
610 |
- " in state %d\n", state); |
|
610 |
+ " in state %d\n", *tmp, state); |
|
611 | 611 |
goto error; |
612 | 612 |
} |
613 | 613 |
break; |
... | ... |
@@ -634,7 +635,7 @@ find_value: |
634 | 634 |
break; |
635 | 635 |
default: |
636 | 636 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
637 |
- " in state %d\n", state); |
|
637 |
+ " in state %d\n", *tmp, state); |
|
638 | 638 |
goto error; |
639 | 639 |
} |
640 | 640 |
break; |
... | ... |
@@ -659,7 +660,7 @@ find_value: |
659 | 659 |
goto end_via; |
660 | 660 |
default: |
661 | 661 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
662 |
- " in state %d\n", state); |
|
662 |
+ " in state %d\n", *tmp, state); |
|
663 | 663 |
goto error; |
664 | 664 |
} |
665 | 665 |
break; |
... | ... |
@@ -678,7 +679,7 @@ find_value: |
678 | 678 |
goto end_via; |
679 | 679 |
default: |
680 | 680 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
681 |
- " in state %d\n", state); |
|
681 |
+ " in state %d\n", *tmp, state); |
|
682 | 682 |
goto error; |
683 | 683 |
} |
684 | 684 |
break; |
... | ... |
@@ -698,7 +699,7 @@ find_value: |
698 | 698 |
goto end_via; |
699 | 699 |
default: |
700 | 700 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
701 |
- " in state %d\n", state); |
|
701 |
+ " in state %d\n", *tmp, state); |
|
702 | 702 |
goto error; |
703 | 703 |
} |
704 | 704 |
break; |
... | ... |
@@ -717,7 +718,7 @@ find_value: |
717 | 717 |
goto end_via; |
718 | 718 |
default: |
719 | 719 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
720 |
- " in state %d\n", state); |
|
720 |
+ " in state %d\n", *tmp, state); |
|
721 | 721 |
goto error; |
722 | 722 |
} |
723 | 723 |
break; /* what to do? */ |
... | ... |
@@ -739,7 +740,7 @@ find_value: |
739 | 739 |
goto end_via; |
740 | 740 |
default: |
741 | 741 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
742 |
- " in state %d\n", state); |
|
742 |
+ " in state %d\n", *tmp, state); |
|
743 | 743 |
goto error; |
744 | 744 |
} |
745 | 745 |
break; |
... | ... |
@@ -759,7 +760,7 @@ find_value: |
759 | 759 |
goto end_via; |
760 | 760 |
default: |
761 | 761 |
LOG(L_ERR, "ERROR: parse_via: invalid char <%c>" |
762 |
- " in state %d\n", state); |
|
762 |
+ " in state %d\n", *tmp, state); |
|
763 | 763 |
goto error; |
764 | 764 |
} |
765 | 765 |
} |
... | ... |
@@ -805,10 +806,8 @@ char* parse_via(char* buffer, char* end, struct via_body *vb) |
805 | 805 |
int state; |
806 | 806 |
int saved_state; |
807 | 807 |
int c_nest; |
808 |
- int i; |
|
809 | 808 |
int err; |
810 | 809 |
|
811 |
- char* tmp_param; |
|
812 | 810 |
struct via_param* param; |
813 | 811 |
|
814 | 812 |
parse_again: |
... | ... |
@@ -139,7 +139,6 @@ void free_hostent(struct hostent *dst) |
139 | 139 |
struct proxy_l* add_proxy(char* name, unsigned short port) |
140 | 140 |
{ |
141 | 141 |
struct proxy_l* p; |
142 |
- struct hostent* he; |
|
143 | 142 |
|
144 | 143 |
if ((p=find_proxy(name, port))!=0) return p; |
145 | 144 |
if ((p=mk_proxy(name, port))==0) goto error; |
... | ... |
@@ -234,8 +233,6 @@ error: |
234 | 234 |
struct proxy_l* mk_proxy_from_ip(unsigned int ip, unsigned short port) |
235 | 235 |
{ |
236 | 236 |
struct proxy_l* p; |
237 |
- struct hostent* he; |
|
238 |
- int err; |
|
239 | 237 |
|
240 | 238 |
p=(struct proxy_l*) malloc(sizeof(struct proxy_l)); |
241 | 239 |
if (p==0){ |
... | ... |
@@ -96,12 +96,13 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip) |
96 | 96 |
LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n"); |
97 | 97 |
goto error; |
98 | 98 |
} |
99 |
- /* |
|
99 |
+#if 0 |
|
100 | 100 |
if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){ |
101 |
- /* no second via => error? / |
|
101 |
+ /* no second via => error? */ |
|
102 | 102 |
LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n"); |
103 | 103 |
goto error; |
104 |
- }*/ |
|
104 |
+ } |
|
105 |
+#endif |
|
105 | 106 |
/* check if via1 == us */ |
106 | 107 |
|
107 | 108 |
#ifdef STATS |
... | ... |
@@ -8,6 +8,7 @@ |
8 | 8 |
#include <dlfcn.h> |
9 | 9 |
#include <strings.h> |
10 | 10 |
#include <stdlib.h> |
11 |
+#include <string.h> |
|
11 | 12 |
|
12 | 13 |
|
13 | 14 |
struct sr_module* modules=0; |
... | ... |
@@ -32,24 +33,34 @@ struct sr_module* modules=0; |
32 | 32 |
/* initializes statically built (compiled in) modules*/ |
33 | 33 |
int init_builtin_modules() |
34 | 34 |
{ |
35 |
+ int ret; |
|
36 |
+ |
|
37 |
+ ret=0; |
|
35 | 38 |
#ifdef STATIC_TM |
36 |
- register_module(tm_mod_register,"built-in", 0); |
|
39 |
+ ret=register_module(tm_mod_register,"built-in", 0); |
|
40 |
+ if (ret<0) return ret; |
|
37 | 41 |
#endif |
38 | 42 |
#ifdef STATIC_MAXFWD |
39 |
- register_module(maxfwd_mod_register, "built-in", 0); |
|
43 |
+ ret=register_module(maxfwd_mod_register, "built-in", 0); |
|
44 |
+ if (ret<0) return ret; |
|
40 | 45 |
#endif |
41 | 46 |
|
42 | 47 |
#ifdef STATIC_AUTH |
43 |
- register_module(tm_mod_register, "built-in", 0); |
|
48 |
+ ret=register_module(tm_mod_register, "built-in", 0); |
|
49 |
+ if (ret<0) return ret; |
|
44 | 50 |
#endif |
45 | 51 |
|
46 | 52 |
#ifdef STATIC_RR |
47 |
- register_module(rr_mod_register, "built-in", 0); |
|
53 |
+ ret=register_module(rr_mod_register, "built-in", 0); |
|
54 |
+ if (ret<0) return ret; |
|
48 | 55 |
#endif |
49 | 56 |
|
50 | 57 |
#ifdef STATIC_USRLOC |
51 |
- register_module(usrloc_mod_register, "built-in", 0); |
|
58 |
+ ret=register_module(usrloc_mod_register, "built-in", 0); |
|
59 |
+ if (ret<0) return ret; |
|
52 | 60 |
#endif |
61 |
+ |
|
62 |
+ return ret; |
|
53 | 63 |
} |
54 | 64 |
|
55 | 65 |
|
... | ... |
@@ -60,7 +71,7 @@ int register_module(module_register register_f, char* path, void* handle) |
60 | 60 |
{ |
61 | 61 |
int ret; |
62 | 62 |
struct module_exports* e; |
63 |
- struct sr_module* t, *mod; |
|
63 |
+ struct sr_module* mod; |
|
64 | 64 |
|
65 | 65 |
ret=-1; |
66 | 66 |
e=(*register_f)(); |
... | ... |
@@ -95,7 +106,8 @@ int init_child(int rank) |
95 | 95 |
for(t = modules; t; t = t->next) { |
96 | 96 |
if (t->exports->init_child_f) { |
97 | 97 |
if ((t->exports->init_child_f(rank)) < 0) { |
98 |
- LOG(L_ERR, "init_child(): Initialization of child with rank %d failed\n"); |
|
98 |
+ LOG(L_ERR, "init_child(): Initialization of child %d failed\n", |
|
99 |
+ rank); |
|
99 | 100 |
return -1; |
100 | 101 |
} |
101 | 102 |
} |
... | ... |
@@ -25,14 +25,13 @@ int udp_sock; |
25 | 25 |
|
26 | 26 |
int probe_max_receive_buffer( int udp_sock ) |
27 | 27 |
{ |
28 |
- int optval, optvallen; |
|
28 |
+ int optval; |
|
29 | 29 |
int ioptval; |
30 | 30 |
unsigned int ioptvallen; |
31 | 31 |
int foptval; |
32 | 32 |
unsigned int foptvallen; |
33 | 33 |
int voptval; |
34 | 34 |
unsigned int voptvallen; |
35 |
- int i; |
|
36 | 35 |
int phase=0; |
37 | 36 |
|
38 | 37 |
/* jku: try to increase buffer size as much as we can */ |
... | ... |
@@ -52,20 +51,21 @@ int probe_max_receive_buffer( int udp_sock ) |
52 | 52 |
for (optval=ioptval; ; ) { |
53 | 53 |
/* increase size; double in initial phase, add linearly later */ |
54 | 54 |
if (phase==0) optval <<= 1; else optval+=BUFFER_INCREMENT; |
55 |
- if (optval > maxbuffer) if (phase==1) break; else { phase=1; optval >>=1; continue; } |
|
55 |
+ if (optval > maxbuffer){ |
|
56 |
+ if (phase==1) break; |
|
57 |
+ } else { phase=1; optval >>=1; continue; } |
|
56 | 58 |
LOG(L_DBG, "DEBUG: udp_init: trying SO_RCVBUF: %d\n", optval ); |
57 |
- if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, |
|
58 |
- (void*)&optval, sizeof(optval)) ==-1) |
|
59 |
- { |
|
59 |
+ if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, |
|
60 |
+ (void*)&optval, sizeof(optval)) ==-1){ |
|
60 | 61 |
/* Solaris returns -1 if asked size too big; Linux ignores */ |
61 |
- LOG(L_DBG, "DEBUG: udp_init: SOL_SOCKET failed for %d, phase %d: %s\n", |
|
62 |
- optval, phase, strerror(errno) ); |
|
62 |
+ LOG(L_DBG, "DEBUG: udp_init: SOL_SOCKET failed" |
|
63 |
+ " for %d, phase %d: %s\n", optval, phase, strerror(errno)); |
|
63 | 64 |
/* if setting buffer size failed and still in the aggressive |
64 | 65 |
phase, try less agressively; otherwise give up |
65 | 66 |
*/ |
66 | 67 |
if (phase==0) { phase=1; optval >>=1 ; continue; } |
67 | 68 |
else break; |
68 |
- } |
|
69 |
+ } |
|
69 | 70 |
/* verify if change has taken effect */ |
70 | 71 |
/* Linux note -- otherwise I would never know that; funny thing: Linux |
71 | 72 |
doubles size for which we asked in setsockopt |
... | ... |
@@ -82,13 +82,13 @@ int probe_max_receive_buffer( int udp_sock ) |
82 | 82 |
if (voptval<optval) { |
83 | 83 |
LOG(L_DBG, "DEBUG: setting SO_RCVBUF has no effect\n"); |
84 | 84 |
/* if setting buffer size failed and still in the aggressive |
85 |
- phase, try less agressively; otherwise give up |
|
85 |
+ phase, try less agressively; otherwise give up |
|
86 | 86 |
*/ |
87 |
- if (phase==0) { phase=1; optval >>=1 ; continue; } |
|
88 |
- else break; |
|
87 |
+ if (phase==0) { phase=1; optval >>=1 ; continue; } |
|
88 |
+ else break; |
|
89 | 89 |
} |
90 | 90 |
} |
91 |
- |
|
91 |
+ |
|
92 | 92 |
} /* for ... */ |
93 | 93 |
foptvallen=sizeof(foptval); |
94 | 94 |
if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &foptval, |
... | ... |
@@ -97,7 +97,7 @@ int probe_max_receive_buffer( int udp_sock ) |
97 | 97 |
LOG(L_ERR, "ERROR: udp_init: getsockopt: %s\n", strerror(errno)); |
98 | 98 |
return -1; |
99 | 99 |
} |
100 |
- LOG(L_INFO, "INFO: udp_init: SO_RCVBUF is finally %d\n", foptval ); |
|
100 |
+ LOG(L_INFO, "INFO: udp_init: SO_RCVBUF is finally %d\n", foptval ); |
|
101 | 101 |
|
102 | 102 |
return 0; |
103 | 103 |
|
... | ... |
@@ -107,7 +107,7 @@ int probe_max_receive_buffer( int udp_sock ) |
107 | 107 |
int udp_init(unsigned long ip, unsigned short port) |
108 | 108 |
{ |
109 | 109 |
struct sockaddr_in* addr; |
110 |
- int optval, optvallen; |
|
110 |
+ int optval; |
|
111 | 111 |
|
112 | 112 |
|
113 | 113 |
addr=(struct sockaddr_in*)malloc(sizeof(struct sockaddr_in)); |
... | ... |
@@ -261,7 +261,7 @@ again: |
261 | 261 |
n=sendto(udp_sock, buf, len, 0, to, tolen); |
262 | 262 |
/* n=sendto(udp_sock, buf, len, 0, &a2, sizeof(struct sockaddr_in) );*/ |
263 | 263 |
if (n==-1){ |
264 |
- LOG(L_ERR, "ERROR: udp_send: sendto(sock,%x,%d,0,%x,%d): %s(%d)\n", |
|
264 |
+ LOG(L_ERR, "ERROR: udp_send: sendto(sock,%p,%d,0,%p,%d): %s(%d)\n", |
|
265 | 265 |
buf,len,to,tolen, |
266 | 266 |
strerror(errno),errno); |
267 | 267 |
if (errno==EINTR) goto again; |
... | ... |
@@ -24,7 +24,9 @@ |
24 | 24 |
|
25 | 25 |
#define trim_r( _mystr ) \ |
26 | 26 |
do{ static char _c; \ |
27 |
- while( ((_mystr).len) && ((_c=(_mystr).s[(_mystr).len-1]))==0 || _c=='\r' || _c=='\n') \ |
|
27 |
+ while( ((_mystr).len) && ( ((_c=(_mystr).s[(_mystr).len-1]))==0 ||\ |
|
28 |
+ _c=='\r' || _c=='\n' ) \ |
|
29 |
+ ) \ |
|
28 | 30 |
(_mystr).len--; \ |
29 | 31 |
}while(0) |
30 | 32 |
|