Browse code

- added syslog suport, changed DPrint to LOG, etc.

Andrei Pelinescu-Onciul authored on 07/09/2001 01:24:32
Showing 8 changed files
... ...
@@ -95,9 +95,10 @@ int cfg_parse_stream(FILE* stream)
95 95
 			switch (cl.type){
96 96
 				case CFG_RULE:
97 97
 					if ((ret=add_rule(&cl, &rlist))!=0){
98
-						DPrint("ERROR: could not compile rule at line %d\n",
99
-							line);
100
-						DPrint(" ----: add_rule returned %d\n", ret);
98
+						LOG(L_CRIT, 
99
+								"ERROR: could not compile rule at line %d\n",
100
+								line);
101
+						LOG(L_CRIT, " ----: add_rule returned %d\n", ret);
101 102
 						goto error;
102 103
 					}
103 104
 					break;
... ...
@@ -105,14 +106,16 @@ int cfg_parse_stream(FILE* stream)
105 105
 				case CFG_SKIP:
106 106
 					break;
107 107
 				case CFG_ERROR:
108
-					DPrint("ERROR: bad config line (%d):%s\n", line, buf);
108
+					LOG(L_CRIT, "ERROR: bad config line (%d):%s\n", line, buf);
109 109
 					goto error;
110 110
 					break;
111 111
 			}
112 112
 			line++;
113 113
 		}else{
114 114
 			if (ferror(stream)){
115
-				DPrint("ERROR: reading configuration: %s\n", strerror(errno));
115
+				LOG(L_CRIT,
116
+						"ERROR: reading configuration: %s\n",
117
+						strerror(errno));
116 118
 				goto error;
117 119
 			}
118 120
 			break;
... ...
@@ -6,6 +6,25 @@
6 6
 #ifndef dprint_h
7 7
 #define dprint_h
8 8
 
9
+#include <syslog.h>
10
+
11
+#include "globals.h"
12
+
13
+#define L_ALERT -3
14
+#define L_CRIT  -2
15
+#define L_ERR   -1
16
+#define L_WARN   1
17
+#define L_NOTICE 2
18
+#define L_INFO   3
19
+#define L_DBG    4
20
+
21
+
22
+
23
+#define DPRINT_LEV	1
24
+/* log facility (see syslog(3)) */
25
+#define L_FAC  LOG_DAEMON
26
+/* priority at which we log */
27
+#define DPRINT_PRIO LOG_DEBUG
9 28
 
10 29
 
11 30
 void dprint (char* format, ...);
... ...
@@ -13,8 +32,54 @@ void dprint (char* format, ...);
13 13
 #ifdef NO_DEBUG
14 14
 	#define DPrint(fmt, args...)
15 15
 #else
16
-	#define DPrint(fmt,args...) dprint(fmt, ## args);
16
+	//#define DPrint(fmt,args...) dprint(fmt, ## args)
17
+	#define DPrint(fmt,args...) \
18
+		do{ \
19
+			if (debug>=DPRINT_LEV){ \
20
+				if (log_stderr){ \
21
+					dprint (fmt, ## args); \
22
+				}else{ \
23
+					syslog(DPRINT_LEV|L_FAC, fmt, ## args); \
24
+				}\
25
+			} \
26
+		}while(0)
27
+
17 28
 #endif
18 29
 
19 30
 
31
+
32
+#define LOG(lev, fmt, args...) \
33
+			do { \
34
+				if (debug>=(lev)){ \
35
+					if (log_stderr) dprint (fmt, ## args); \
36
+					else { \
37
+						switch(lev){ \
38
+							case L_CRIT: \
39
+								syslog(LOG_CRIT | L_FAC, fmt, ##args); \
40
+								break; \
41
+							case L_ALERT: \
42
+								syslog(LOG_ALERT | L_FAC, fmt, ##args); \
43
+								break; \
44
+							case L_ERR: \
45
+								syslog(LOG_ERR | L_FAC, fmt, ##args); \
46
+								break; \
47
+							case L_WARN: \
48
+								syslog(LOG_WARNING | L_FAC, fmt, ##args); \
49
+								break; \
50
+							case L_NOTICE: \
51
+								syslog(LOG_NOTICE | L_FAC, fmt, ##args); \
52
+								break; \
53
+							case L_INFO: \
54
+								syslog(LOG_INFO | L_FAC, fmt, ##args); \
55
+								break; \
56
+							case L_DBG: \
57
+								syslog(LOG_DEBUG | L_FAC, fmt, ##args); \
58
+								break; \
59
+						} \
60
+					} \
61
+				} \
62
+			}while(0)
63
+
64
+#define DBG(fmt, args...) LOG(L_DBG, fmt, ## args)
65
+
20 66
 #endif /* ifndef dprint_h */
... ...
@@ -76,7 +76,7 @@ int forward_request(char * orig, char* buf,
76 76
 	to=0;
77 77
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
78 78
 	if (to==0){
79
-		DPrint("ERROR: forward_reply: out of memory\n");
79
+		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
80 80
 		goto error;
81 81
 	}
82 82
 
... ...
@@ -92,7 +92,7 @@ int forward_request(char * orig, char* buf,
92 92
 	new_len=len+via_len+received_len;
93 93
 	new_buf=(char*)malloc(new_len+1);
94 94
 	if (new_buf==0){
95
-		DPrint("ERROR: forward_request: out of memory\n");
95
+		LOG(L_ERR, "ERROR: forward_request: out of memory\n");
96 96
 		goto error;
97 97
 	}
98 98
 /* copy msg till first via */
... ...
@@ -126,8 +126,8 @@ int forward_request(char * orig, char* buf,
126 126
 	new_buf[new_len]=0;
127 127
 
128 128
 	 /* send it! */
129
-	printf("Sending:\n%s.\n", new_buf);
130
-	printf("orig. len=%d, new_len=%d, via_len=%d, received_len=%d\n",
129
+	DBG("Sending:\n%s.\n", new_buf);
130
+	DBG("orig. len=%d, new_len=%d, via_len=%d, received_len=%d\n",
131 131
 			len, new_len, via_len, received_len);
132 132
 
133 133
 	to->sin_family = AF_INET;
... ...
@@ -178,7 +178,7 @@ int forward_reply(char * orig, char* buf,
178 178
 	to=0;
179 179
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
180 180
 	if (to==0){
181
-		DPrint("ERROR: forward_reply: out of memory\n");
181
+		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
182 182
 		goto error;
183 183
 	}
184 184
 
... ...
@@ -187,7 +187,7 @@ int forward_reply(char * orig, char* buf,
187 187
 		for (r=0; r<addresses_no; r++)
188 188
 			if(strcmp(msg->via1.host, names[r])==0) break;
189 189
 		if (r==addresses_no){
190
-			DPrint("ERROR: forward_reply: host in first via != me : %s\n",
190
+			LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me : %s\n",
191 191
 					msg->via1.host);
192 192
 			/* send error msg back? */
193 193
 			goto error;
... ...
@@ -196,21 +196,21 @@ int forward_reply(char * orig, char* buf,
196 196
 	/* we must remove the first via */
197 197
 	via_len=msg->via1.size;
198 198
 	size=msg->via1.hdr-buf;
199
-	printf("via len: %d, initial size: %d\n", via_len, size);
199
+	DBG("via len: %d, initial size: %d\n", via_len, size);
200 200
 	if (msg->via1.next){
201 201
 		/* keep hdr =substract hdr size +1 (hdr':') and add
202 202
 		 */
203 203
 		via_len-=strlen(msg->via1.hdr)+1;
204 204
 		size+=strlen(msg->via1.hdr)+1;
205
-	    printf(" adjusted via len: %d, initial size: %d\n",
205
+	    DBG(" adjusted via len: %d, initial size: %d\n",
206 206
 				via_len, size);
207 207
 	}
208 208
 	new_len=len-via_len;
209 209
 	
210
-	printf(" old size: %d, new size: %d\n", len, new_len);
210
+	DBG(" old size: %d, new size: %d\n", len, new_len);
211 211
 	new_buf=(char*)malloc(new_len+1);/* +1 is for debugging (\0 to print it )*/
212 212
 	if (new_buf==0){
213
-		DPrint("ERROR: forward_reply: out of memory\n");
213
+		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
214 214
 		goto error;
215 215
 	}
216 216
 	new_buf[new_len]=0; /* debug: print the message */
... ...
@@ -219,17 +219,18 @@ int forward_reply(char * orig, char* buf,
219 219
 	s_offset=size+via_len;
220 220
 	memcpy(new_buf+offset,orig+s_offset, len-s_offset);
221 221
 	 /* send it! */
222
-	printf(" copied size: orig:%d, new: %d, rest: %d\n",
222
+	DBG(" copied size: orig:%d, new: %d, rest: %d\n",
223 223
 			s_offset, offset, 
224 224
 			len-s_offset );
225
-	printf("Sending: to %s:%d, \n%s.\n",
225
+	DBG("Sending: to %s:%d, \n%s.\n",
226 226
 			msg->via2.host, 
227 227
 			(unsigned short)msg->via2.port,
228 228
 			new_buf);
229 229
 	/* fork? gethostbyname will probably block... */
230 230
 	he=gethostbyname(msg->via2.host);
231 231
 	if (he==0){
232
-		DPrint("ERROR:forward_reply:gethostbyname failure\n");
232
+		LOG(L_NOTICE, "ERROR:forward_reply:gethostbyname(%s) failure\n",
233
+				msg->via2.host);
233 234
 		goto error;
234 235
 	}
235 236
 	to->sin_family = AF_INET;
... ...
@@ -212,13 +212,13 @@ int main(int argc, char** argv)
212 212
 	/* load config file or die */
213 213
 	cfg_stream=fopen (cfg_file, "r");
214 214
 	if (cfg_stream==0){
215
-		DPrint("ERROR: loading config file(%s): %s\n", cfg_file,
215
+		fprintf(stderr, "ERROR: loading config file(%s): %s\n", cfg_file,
216 216
 				strerror(errno));
217 217
 		goto error;
218 218
 	}
219 219
 
220 220
 	if (cfg_parse_stream(cfg_stream)!=0){
221
-		DPrint("ERROR: config parser failure\n");
221
+		fprintf(stderr, "ERROR: config parser failure\n");
222 222
 		goto error;
223 223
 	}
224 224
 	
... ...
@@ -40,7 +40,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
40 40
 	/* see if it's a reply (status) */
41 41
 	tmp=eat_token(buffer, len);
42 42
 	if ((tmp==buffer)||(tmp>=end)){
43
-		DPrint("ERROR: empty  or bad first line\n");
43
+		LOG(L_INFO, "ERROR:parse_first_line: empty  or bad first line\n");
44 44
 		goto error1;
45 45
 	}
46 46
 	if ((strlen(SIP_VERSION)==(tmp-buffer)) &&
... ...
@@ -103,11 +103,11 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
103 103
 	return nl;
104 104
 
105 105
 error:
106
-	DPrint("ERROR: bad %s first line\n", 
106
+	LOG(L_INFO, "ERROR:parse_first_line: bad %s first line\n", 
107 107
 		(fl->type==SIP_REPLY)?"reply(status)":"request");
108 108
 error1:
109 109
 	fl->type=SIP_INVALID;
110
-	DPrint("ERROR: at line 0 char %d\n", offset);
110
+	LOG(L_INFO, "ERROR: at line 0 char %d\n", offset);
111 111
 	/* skip  line */
112 112
 	nl=eat_line(buffer,len);
113 113
 	return nl;
... ...
@@ -168,7 +168,7 @@ char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field*  hdr_f)
168 168
 	}while( (*tmp==' ' ||  *tmp=='\t') && (offset<len) );
169 169
 	if (offset==len){
170 170
 		hdr_f->type=HDR_ERROR;
171
-		DPrint("ERROR: field body too  long\n");
171
+		LOG(L_INFO, "ERROR: het_hdr_field: field body too  long\n");
172 172
 		goto error;
173 173
 	}
174 174
 	*(tmp-1)=0; /* should be an LF */
... ...
@@ -193,7 +193,8 @@ char* parse_hostport(char* buf, char** host, short int* port)
193 193
 		invalid=0;
194 194
 		*port=strtol(tmp+1, &invalid, 10);
195 195
 		if ((invalid!=0)&&(*invalid)){
196
-			DPrint("ERROR: hostport: trailing chars in port number: %s(%x)\n",
196
+			LOG(L_INFO, 
197
+					"ERROR: hostport: trailing chars in port number: %s(%x)\n",
197 198
 					invalid, invalid);
198 199
 			/* report error? */
199 200
 		}
... ...
@@ -362,23 +363,23 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
362 362
 	tmp=rest;
363 363
 	switch(fl.type){
364 364
 		case SIP_INVALID:
365
-			DPrint("invalid message\n");
365
+			DBG("parse_msg: invalid message\n");
366 366
 			goto error;
367 367
 			break;
368 368
 		case SIP_REQUEST:
369
-			DPrint("SIP Request:\n");
370
-			DPrint(" method:  <%s>\n",fl.u.request.method);
371
-			DPrint(" uri:     <%s>\n",fl.u.request.uri);
372
-			DPrint(" version: <%s>\n",fl.u.request.version);
369
+			DBG("SIP Request:\n");
370
+			DBG(" method:  <%s>\n",fl.u.request.method);
371
+			DBG(" uri:     <%s>\n",fl.u.request.uri);
372
+			DBG(" version: <%s>\n",fl.u.request.version);
373 373
 			break;
374 374
 		case SIP_REPLY:
375
-			DPrint("SIP Reply  (status):\n");
376
-			DPrint(" version: <%s>\n",fl.u.reply.version);
377
-			DPrint(" status:  <%s>\n",fl.u.reply.status);
378
-			DPrint(" reason:  <%s>\n",fl.u.reply.reason);
375
+			DBG("SIP Reply  (status):\n");
376
+			DBG(" version: <%s>\n",fl.u.reply.version);
377
+			DBG(" status:  <%s>\n",fl.u.reply.status);
378
+			DBG(" reason:  <%s>\n",fl.u.reply.reason);
379 379
 			break;
380 380
 		default:
381
-			DPrint("unknown type %d\n",fl.type);
381
+			DBG("unknown type %d\n",fl.type);
382 382
 	}
383 383
 	
384 384
 	/*find first Via: */
... ...
@@ -390,7 +391,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
390 390
 		offset+=rest-tmp;
391 391
 		switch (hf.type){
392 392
 			case HDR_ERROR:
393
-				DPrint("ERROR: bad header  field\n");
393
+				LOG(L_INFO,"ERROR: bad header  field\n");
394 394
 				goto  error;
395 395
 			case HDR_EOH: 
396 396
 				goto skip;
... ...
@@ -402,11 +403,12 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
402 402
 						for (bar=first_via;(first_via) && (*bar);bar++)
403 403
 							if ((*bar=='\r')||(*bar=='\n'))	*bar=' ';
404 404
 				#ifdef DEBUG
405
-						printf("first via: <%s>\n", first_via);
405
+						DBG("first via: <%s>\n", first_via);
406 406
 				#endif
407 407
 						bar=parse_via_body(first_via, strlen(first_via), &vb1);
408 408
 						if (vb1.error!=VIA_PARSE_OK){
409
-							DPrint("ERROR: parsing via body: %s\n", first_via);
409
+							LOG(L_INFO, "ERROR: parsing via body: %s\n",
410
+									first_via);
410 411
 							goto error;
411 412
 						}
412 413
 						
... ...
@@ -430,7 +432,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
430 430
 				break;
431 431
 		}
432 432
 	#ifdef DEBUG
433
-		printf("header field type %d, name=<%s>, body=<%s>\n",
433
+		DBG("header field type %d, name=<%s>, body=<%s>\n",
434 434
 			hf.type, hf.name, hf.body);
435 435
 	#endif
436 436
 		tmp=rest;
... ...
@@ -444,7 +446,7 @@ skip:
444 444
 	if (second_via) {
445 445
 		tmp=parse_via_body(second_via, strlen(second_via), &vb2);
446 446
 		if (vb2.error!=VIA_PARSE_OK){
447
-			DPrint("ERROR: parsing via2 body: %s\n", second_via);
447
+			LOG(L_INFO, "ERROR: parsing via2 body: %s\n", second_via);
448 448
 			goto error;
449 449
 		}
450 450
 		vb2.size=tmp-second_via; 
... ...
@@ -455,17 +457,17 @@ skip:
455 455
 
456 456
 #ifdef DEBUG
457 457
 	/* dump parsed data */
458
-	printf(" first  via: <%s/%s/%s> <%s:%d>",
458
+	DBG(" first  via: <%s/%s/%s> <%s:%d>",
459 459
 			vb1.name, vb1.version, vb1.transport, vb1.host, vb1.port);
460
-	if (vb1.params) printf(";<%s>", vb1.params);
461
-	if (vb1.comment) printf(" <%s>", vb1.comment);
462
-	printf ("\n");
460
+	if (vb1.params)  DBG(";<%s>", vb1.params);
461
+	if (vb1.comment) DBG(" <%s>", vb1.comment);
462
+	DBG ("\n");
463 463
 	if (second_via){
464
-		printf(" second via: <%s/%s/%s> <%s:%d>",
464
+		DBG(" second via: <%s/%s/%s> <%s:%d>",
465 465
 				vb2.name, vb2.version, vb2.transport, vb2.host, vb2.port);
466
-		if (vb2.params) printf(";<%s>", vb2.params);
467
-		if (vb2.comment) printf(" <%s>", vb2.comment);
468
-		printf ("\n");
466
+		if (vb2.params)  DBG(";<%s>", vb2.params);
467
+		if (vb2.comment) DBG(" <%s>", vb2.comment);
468
+		DBG("\n");
469 469
 	}
470 470
 #endif
471 471
 	
... ...
@@ -475,7 +477,7 @@ skip:
475 475
 	memcpy(&(msg->via2), &vb2, sizeof(struct via_body));
476 476
 
477 477
 #ifdef DEBUG
478
-	printf ("exiting parse_msg\n");
478
+	DBG("exiting parse_msg\n");
479 479
 #endif
480 480
 
481 481
 	return 0;
... ...
@@ -20,7 +20,7 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
20 20
 	/* make a copy of the message */
21 21
 	orig=(char*) malloc(len);
22 22
 	if (orig==0){
23
-		DPrint("ERROR: memory allocation failure\n");
23
+		LOG(L_ERR, "ERROR:receive_msg: memory allocation failure\n");
24 24
 		goto error1;
25 25
 	}
26 26
 	memcpy(orig, buf, len);
... ...
@@ -44,12 +44,12 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
44 44
 					  );
45 45
 		if (re==0){
46 46
 			/* no route found, send back error msg? */
47
-			DPrint("WARNING: no route found!\n");
47
+			LOG(L_WARN, "WARNING: receive_msg: no route found!\n");
48 48
 			goto skip;
49 49
 		}
50 50
 		re->tx++;
51 51
 		/* send msg */
52
-		DPrint(" found route to: %s\n", re->host.h_name);
52
+		DBG(" found route to: %s\n", re->host.h_name);
53 53
 		forward_request(orig, buf, len, &msg, re, src_ip);
54 54
 	}else if (msg.first_line.type==SIP_REPLY){
55 55
 		/* sanity checks */
... ...
@@ -65,7 +65,7 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
65 65
 		
66 66
 		/* send the msg */
67 67
 		if (forward_reply(orig, buf, len, &msg)==0){
68
-			DPrint(" reply forwarded to %s:%d\n", 
68
+			DBG(" reply forwarded to %s:%d\n", 
69 69
 						msg.via2.host,
70 70
 						(unsigned short) msg.via2.port);
71 71
 		}
... ...
@@ -95,12 +95,12 @@ int add_rule(struct cfg_line* cl, struct route_elem** head)
95 95
 	if (re==0) return E_OUT_OF_MEM;
96 96
 
97 97
 	if (regcomp(&(re->method), cl->method, REG_EXTENDED|REG_NOSUB|REG_ICASE)){
98
-		DPrint("ERROR: bad re \"%s\"\n", cl->method);
98
+		LOG(L_CRIT, "ERROR: add_rule: bad re \"%s\"\n", cl->method);
99 99
 		ret=E_BAD_RE;
100 100
 		goto error;
101 101
 	}
102 102
 	if (regcomp(&(re->uri), cl->uri, REG_EXTENDED|REG_NOSUB|REG_ICASE) ){
103
-		DPrint("ERROR: bad re \"%s\"\n", cl->uri);
103
+		LOG(L_CRIT, "ERROR: add_rule: bad re \"%s\"\n", cl->uri);
104 104
 		ret=E_BAD_RE;
105 105
 		goto error;
106 106
 	}
... ...
@@ -108,7 +108,7 @@ int add_rule(struct cfg_line* cl, struct route_elem** head)
108 108
 	
109 109
 	he=gethostbyname(cl->address);
110 110
 	if (he==0){
111
-		DPrint("ERROR: cannot resolve \"%s\"\n", cl->address);
111
+		LOG(L_CRIT, "ERROR: add_rule: cannot resolve \"%s\"\n", cl->address);
112 112
 		ret=E_BAD_ADDRESS;
113 113
 		goto error;
114 114
 	}
... ...
@@ -181,7 +181,7 @@ struct route_elem* route_match(char* method, char* uri, struct route_elem** rl)
181 181
 {
182 182
 	struct route_elem* t;
183 183
 	if (*rl==0){
184
-		DPrint("WARNING: empty routing table\n");
184
+		LOG(L_ERR, "WARNING: route_match: empty routing table\n");
185 185
 		return 0;
186 186
 	}
187 187
 	for (t=*rl; t; t=t->next){
... ...
@@ -206,25 +206,25 @@ void print_rl()
206 206
 	int i,j;
207 207
 
208 208
 	if (rlist==0){
209
-		DPrint("the routing table is empty\n");
209
+		LOG(L_INFO, "the routing table is empty\n");
210 210
 		return;
211 211
 	}
212 212
 	
213 213
 	for (t=rlist,i=0; t; i++, t=t->next){
214
-		DPrint("%2d.to=%s ; route ok=%d\n", i,
214
+		LOG(L_INFO, "%2d.to=%s ; route ok=%d\n", i,
215 215
 				t->host.h_name, t->ok);
216
-		DPrint("   ips: ");
216
+		LOG(L_INFO, "   ips: ");
217 217
 		for (j=0; t->host.h_addr_list[j]; j++){
218
-			DPrint("%d.%d.%d.%d ", 
218
+			LOG(L_INFO, "%d.%d.%d.%d ", 
219 219
 				(unsigned char) t->host.h_addr_list[j][0],
220 220
 				(unsigned char) t->host.h_addr_list[j][1],
221 221
 			    (unsigned char) t->host.h_addr_list[j][2],
222 222
 				(unsigned char) t->host.h_addr_list[j][3]
223 223
 				  );
224 224
 		}
225
-		DPrint("\n");
226
-		DPrint("   port:%d\n", (unsigned short)t->port);
227
-		DPrint("   Statistics: tx=%d, errors=%d, tx_bytes=%d, idx=%d\n",
225
+		LOG(L_INFO, "\n");
226
+		LOG(L_INFO, "   port:%d\n", (unsigned short)t->port);
227
+		LOG(L_INFO, "   Statistics: tx=%d, errors=%d, tx_bytes=%d, idx=%d\n",
228 228
 				t->tx, t->errors, t->tx_bytes, t->current_addr_idx);
229 229
 	}
230 230
 
... ...
@@ -24,7 +24,7 @@ int udp_init(unsigned long ip, unsigned short port)
24 24
 
25 25
 	addr=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
26 26
 	if (addr==0){
27
-		DPrint("ERROR: udp_init: out of memory\n");
27
+		LOG(L_ERR, "ERROR: udp_init: out of memory\n");
28 28
 		goto error;
29 29
 	}
30 30
 	addr->sin_family=AF_INET;
... ...
@@ -33,7 +33,7 @@ int udp_init(unsigned long ip, unsigned short port)
33 33
 
34 34
 	udp_sock = socket(PF_INET, SOCK_DGRAM, 0);
35 35
 	if (udp_sock==-1){
36
-		DPrint("ERROR: udp_init: socket: %s\n", strerror());
36
+		LOG(L_ERR, "ERROR: udp_init: socket: %s\n", strerror());
37 37
 		goto error;
38 38
 	}
39 39
 	/* set sock opts? */
... ...
@@ -41,12 +41,12 @@ int udp_init(unsigned long ip, unsigned short port)
41 41
 	if (setsockopt(udp_sock, SOL_SOCKET, SO_REUSEADDR,
42 42
 					(void*)&optval, sizeof(optval)) ==-1)
43 43
 	{
44
-		DPrint("ERROR: udp_init: setsockopt: %s\n", strerror());
44
+		LOG(L_ERR, "ERROR: udp_init: setsockopt: %s\n", strerror());
45 45
 		goto error;
46 46
 	}
47 47
 
48 48
 	if (bind(udp_sock, (struct sockaddr*) addr, sizeof(struct sockaddr))==-1){
49
-		DPrint("ERROR: udp_init: bind: %s\n", strerror());
49
+		LOG(L_ERR, "ERROR: udp_init: bind: %s\n", strerror());
50 50
 		goto error;
51 51
 	}
52 52
 
... ...
@@ -69,7 +69,7 @@ int udp_rcv_loop()
69 69
 
70 70
 	from=(struct sockaddr*) malloc(sizeof(struct sockaddr));
71 71
 	if (from==0){
72
-		DPrint("ERROR: udp_rcv_loop: out of memory\n");
72
+		LOG(L_ERR, "ERROR: udp_rcv_loop: out of memory\n");
73 73
 		goto error;
74 74
 	}
75 75
 
... ...
@@ -77,7 +77,7 @@ int udp_rcv_loop()
77 77
 		fromlen=sizeof(struct sockaddr);
78 78
 		len=recvfrom(udp_sock, buf, BUF_SIZE, 0, from, &fromlen);
79 79
 		if (len==-1){
80
-			DPrint("ERROR: udp_rcv_loop:recvfrom: %s\n", strerror());
80
+			LOG(L_ERR, "ERROR: udp_rcv_loop:recvfrom: %s\n", strerror());
81 81
 			if (errno==EINTR)	goto skip;
82 82
 			else goto error;
83 83
 		}
... ...
@@ -108,7 +108,7 @@ int udp_send(char *buf, int len, struct sockaddr*  to, int tolen)
108 108
 again:
109 109
 	n=sendto(udp_sock, buf, len, 0, to, tolen);
110 110
 	if (n==-1){
111
-		DPrint("ERROR: udp_send: sendto: %s\n", strerror());
111
+		LOG(L_ERR, "ERROR: udp_send: sendto: %s\n", strerror());
112 112
 		if (errno==EINTR) goto again;
113 113
 	}
114 114
 	return n;