Browse code

forward.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 03/10/2014 21:08:23
Showing 1 changed files
... ...
@@ -143,7 +143,7 @@ struct socket_info* get_out_socket(union sockaddr_union* to, int proto)
143 143
 	uncon.sin.sin_family = AF_UNSPEC;
144 144
 
145 145
 	if (unlikely(proto!=PROTO_UDP)) {
146
-		LOG(L_CRIT, "BUG: get_out_socket can only be called for UDP\n");
146
+		LM_CRIT("can only be called for UDP\n");
147 147
 		return 0;
148 148
 	}
149 149
 retry:
... ...
@@ -197,14 +197,12 @@ retry:
197 197
 			}
198 198
 			goto retry;
199 199
 		}
200
-		LOG(L_ERR, "ERROR: get_out_socket: connect failed: %s\n",
201
-				strerror(errno));
200
+		LM_ERR("connect failed: %s\n", strerror(errno));
202 201
 		goto error;
203 202
 	}
204 203
 	len=sizeof(from);
205 204
 	if (unlikely(getsockname(*temp_sock, &from.s, &len)==-1)) {
206
-		LOG(L_ERR, "ERROR: get_out_socket: getsockname failed: %s\n",
207
-				strerror(errno));
205
+		LM_ERR("getsockname failed: %s\n", strerror(errno));
208 206
 		goto error;
209 207
 	}
210 208
 	su2ip_addr(&ip, &from);
... ...
@@ -217,7 +215,7 @@ retry:
217 215
 	}
218 216
 	return si;
219 217
 error:
220
-	LOG(L_ERR, "ERROR: get_out_socket: no socket found\n");
218
+	LM_ERR("no socket found\n");
221 219
 	ERR("no corresponding socket found for(%s:%s)\n",
222 220
 			proto2a(proto), su2a(to, sizeof(*to)));
223 221
 	if (unlikely(mhomed_sock_cache_disabled && *temp_sock >=0)){
... ...
@@ -264,9 +262,7 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
264 262
 											proto);
265 263
 			if (unlikely(force_send_socket == 0)){
266 264
 				if (likely(mismatch)) *mismatch=SS_MISMATCH_ADDR;
267
-				LOG(L_WARN, "WARNING: get_send_socket: "
268
-						"protocol/port mismatch (forced %s:%s:%d,"
269
-						" to %s:%s)\n",
265
+				LM_WARN("protocol/port mismatch (forced %s:%s:%d, to %s:%s)\n",
270 266
 						proto2a(orig->proto), ip_addr2a(&orig->address),
271 267
 						orig->port_no,
272 268
 						proto2a(proto), su2a(to, sizeof(*to)));
... ...
@@ -297,8 +293,7 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
297 293
 				return force_send_socket;
298 294
 		else{
299 295
 			if (!(force_send_socket->flags & SI_IS_MCAST))
300
-				LOG(L_WARN, "WARNING: get_send_socket: not listening"
301
-							 " on the requested socket (%s:%s:%d),"
296
+				LM_WARN("not listening on the requested socket (%s:%s:%d),"
302 297
 							 " no fork mode?\n",
303 298
 							proto2a(force_send_socket->proto),
304 299
 							ip_addr2a(&force_send_socket->address),
... ...
@@ -312,7 +307,7 @@ not_forced:
312 307
 		if ((send_sock==0) || (send_sock->socket!=-1))
313 308
 			return send_sock; /* found or error*/
314 309
 		else if (send_sock->socket==-1){
315
-			LOG(L_WARN, "WARNING: get_send_socket: not listening on the"
310
+			LM_WARN("not listening on the"
316 311
 					" requested socket (%s:%s:%d), no fork mode?\n",
317 312
 					proto2a(send_sock->proto), ip_addr2a(&send_sock->address),
318 313
 					send_sock->port_no);
... ...
@@ -336,8 +331,8 @@ not_forced:
336 331
 								break;
337 332
 				case AF_INET6:	send_sock=sendipv6_tcp;
338 333
 								break;
339
-				default:	LOG(L_ERR, "get_send_socket: BUG: don't know how"
340
-									" to forward to af %d\n", to->s.sa_family);
334
+				default:	LM_ERR("don't know how to forward to af %d\n",
335
+									to->s.sa_family);
341 336
 			}
342 337
 			break;
343 338
 #endif
... ...
@@ -350,8 +345,8 @@ not_forced:
350 345
 								break;
351 346
 				case AF_INET6:	send_sock=sendipv6_tls;
352 347
 								break;
353
-				default:	LOG(L_ERR, "get_send_socket: BUG: don't know how"
354
-									" to forward to af %d\n", to->s.sa_family);
348
+				default:	LM_ERR("don't know how to forward to af %d\n",
349
+									to->s.sa_family);
355 350
 			}
356 351
 			break;
357 352
 #endif /* USE_TLS */
... ...
@@ -365,8 +360,7 @@ not_forced:
365 360
 									break;
366 361
 					case AF_INET6:	send_sock=sendipv6_sctp;
367 362
 									break;
368
-					default:	LOG(L_ERR, "get_send_socket: BUG: don't know"
369
-										" how to forward to af %d\n",
363
+					default:	LM_ERR("don't know how to forward to af %d\n",
370 364
 										to->s.sa_family);
371 365
 				}
372 366
 			}else send_sock=bind_address;
... ...
@@ -381,15 +375,13 @@ not_forced:
381 375
 									break;
382 376
 					case AF_INET6:	send_sock=sendipv6;
383 377
 									break;
384
-					default:	LOG(L_ERR, "get_send_socket: BUG: don't know"
385
-										" how to forward to af %d\n",
378
+					default:	LM_ERR("don't know how to forward to af %d\n",
386 379
 										to->s.sa_family);
387 380
 				}
388 381
 			}else send_sock=bind_address;
389 382
 			break;
390 383
 		default:
391
-			LOG(L_CRIT, "BUG: get_send_socket: unsupported proto %d (%s)\n",
392
-					proto, proto2a(proto));
384
+			LM_CRIT("unsupported proto %d (%s)\n", proto, proto2a(proto));
393 385
 	}
394 386
 	return send_sock;
395 387
 }
... ...
@@ -528,17 +520,15 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
528 520
 			err=dns_sip_resolve2su(&dns_srv_h, &send_info->to, dst, port,
529 521
 									&proto, dns_flags);
530 522
 			if (err!=0){
531
-				LOG(L_ERR, "ERROR: forward_request: resolving \"%.*s\""
532
-						" failed: %s [%d]\n", dst->len, ZSW(dst->s),
533
-						dns_strerror(err), err);
523
+				LM_ERR("resolving \"%.*s\" failed: %s [%d]\n",
524
+						dst->len, ZSW(dst->s), dns_strerror(err), err);
534 525
 				ret=E_BAD_ADDRESS;
535 526
 				goto error;
536 527
 			}
537 528
 		}else
538 529
 #endif
539 530
 		if (sip_hostport2su(&send_info->to, dst, port, &proto)<0){
540
-			LOG(L_ERR, "ERROR: forward_request: bad host name %.*s,"
541
-						" dropping packet\n", dst->len, ZSW(dst->s));
531
+			LM_ERR("bad host name %.*s, dropping packet\n", dst->len, ZSW(dst->s));
542 532
 			ret=E_BAD_ADDRESS;
543 533
 			goto error;
544 534
 		}
... ...
@@ -551,14 +541,14 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
551 541
 	   with the same branch parameter and will be match-able downstream
552 542
 	*/
553 543
 	if (!char_msg_val( msg, md5 )) 	{ /* parses transaction key */
554
-		LOG(L_ERR, "ERROR: forward_request: char_msg_val failed\n");
544
+		LM_ERR("char_msg_val failed\n");
555 545
 		ret=E_UNSPEC;
556 546
 		goto error;
557 547
 	}
558 548
 	msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number);
559 549
 	if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */,
560 550
 				msg->add_to_branch_s, &msg->add_to_branch_len )) {
561
-		LOG(L_ERR, "ERROR: forward_request: branch_builder failed\n");
551
+		LM_ERR("branch_builder failed\n");
562 552
 		ret=E_UNSPEC;
563 553
 		goto error;
564 554
 	}
... ...
@@ -570,7 +560,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
570 560
 		if (orig_send_sock==0) /* no forced send_sock => find it **/
571 561
 			send_info->send_sock=get_send_socket(msg, &send_info->to, proto);
572 562
 		if (send_info->send_sock==0){
573
-			LOG(L_ERR, "forward_req: ERROR: cannot forward to af %d, proto %d "
563
+			LM_ERR("cannot forward to af %d, proto %d "
574 564
 						"no corresponding listening socket\n",
575 565
 						send_info->to.s.sa_family, proto);
576 566
 			ret=ser_error=E_NO_SOCKET;
... ...
@@ -591,7 +581,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
591 581
 			send_info->proto=proto;
592 582
 			buf = build_req_buf_from_sip_req(msg, &len, send_info, 0);
593 583
 			if (!buf){
594
-				LOG(L_ERR, "ERROR: forward_request: building failed\n");
584
+				LM_ERR("building failed\n");
595 585
 				ret=E_OUT_OF_MEM; /* most probable */
596 586
 				goto error;
597 587
 			}
... ...
@@ -605,9 +595,8 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
605 595
 	
606 596
 		if (run_onsend(msg, send_info, buf, len)==0){
607 597
 			su2ip_addr(&ip, &send_info->to);
608
-			LOG(L_INFO, "forward_request: request to %s:%d(%d) dropped"
609
-					" (onsend_route)\n", ip_addr2a(&ip),
610
-						su_getport(&send_info->to), send_info->proto);
598
+			LM_INFO("request to %s:%d(%d) dropped (onsend_route)\n",
599
+				ip_addr2a(&ip), su_getport(&send_info->to), send_info->proto);
611 600
 			ser_error=E_OK; /* no error */
612 601
 			ret=E_ADM_PROHIBITED;
613 602
 #ifdef USE_DNS_FAILOVER
... ...
@@ -620,9 +609,8 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
620 609
 		if (cfg_get(core, core_cfg, use_dst_blacklist)){
621 610
 			if (dst_is_blacklisted(send_info, msg)){
622 611
 				su2ip_addr(&ip, &send_info->to);
623
-				LOG(L_DBG, "DEBUG: blacklisted destination:%s:%d (%d)\n",
624
-							ip_addr2a(&ip), su_getport(&send_info->to),
625
-							send_info->proto);
612
+				LM_DBG("blacklisted destination:%s:%d (%d)\n",
613
+					ip_addr2a(&ip), su_getport(&send_info->to), send_info->proto);
626 614
 				ret=ser_error=E_SEND;
627 615
 #ifdef USE_DNS_FAILOVER
628 616
 				continue; /* try another ip */
... ...
@@ -667,8 +655,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
667 655
 			((err=dns_sip_resolve2su(&dns_srv_h, &send_info->to, dst, port,
668 656
 										&proto, dns_flags))==0));
669 657
 	if ((err!=0) && (err!=-E_DNS_EOR)){
670
-		LOG(L_ERR, "ERROR:  resolving %.*s host name in uri"
671
-							" failed: %s [%d] (dropping packet)\n",
658
+		LM_ERR("resolving %.*s host name in uri failed: %s [%d] (dropping packet)\n",
672 659
 									dst->len, ZSW(dst->s),
673 660
 									dns_strerror(err), err);
674 661
 		ret=ser_error=E_BAD_ADDRESS;
... ...
@@ -723,7 +710,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
723 710
 			DBG("update_sock_struct_from_via: using 'rport'\n");
724 711
 			port=str2s(via->rport->value.s, via->rport->value.len, &err);
725 712
 			if (err){
726
-				LOG(L_NOTICE, "ERROR: update_sock_struct_from_via: bad rport value(%.*s)\n",
713
+				LM_ERR("bad rport value(%.*s)\n",
727 714
 						via->rport->value.len, via->rport->value.s);
728 715
 				port=0;
729 716
 			}
... ...
@@ -753,9 +740,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
753 740
 	he=sip_resolvehost(name, &port, &proto);
754 741
 	
755 742
 	if (he==0){
756
-		LOG(L_NOTICE,
757
-				"update_sock_struct_from_via:resolve_host(%.*s) failure\n",
758
-				name->len, name->s);
743
+		LM_NOTICE("resolve_host(%.*s) failure\n", name->len, name->s);
759 744
 		return -1;
760 745
 	}
761 746
 		
... ...
@@ -784,9 +769,8 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
784 769
 		if (check_self(&msg->via1->host,
785 770
 					msg->via1->port?msg->via1->port:SIP_PORT,
786 771
 					msg->via1->proto)!=1){
787
-			LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me :"
788
-					" %.*s:%d\n", msg->via1->host.len, msg->via1->host.s,
789
-									msg->via1->port);
772
+			LM_ERR("host in first via!=me : %.*s:%d\n",
773
+				msg->via1->host.len, msg->via1->host.s, msg->via1->port);
790 774
 			/* send error msg back? */
791 775
 			goto error;
792 776
 		}
... ...
@@ -802,13 +786,13 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
802 786
 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
803 787
 	{
804 788
 		/* no second via => error */
805
-		LOG(L_DBG, "reply cannot be forwarded - no 2nd via\n");
789
+		LM_DBG("reply cannot be forwarded - no 2nd via\n");
806 790
 		goto error;
807 791
 	}
808 792
 
809 793
 	new_buf = build_res_buf_from_sip_res( msg, &new_len);
810 794
 	if (!new_buf){
811
-		LOG(L_ERR, "ERROR: forward_reply: building failed\n");
795
+		LM_ERR("building failed\n");
812 796
 		goto error;
813 797
 	}
814 798
 
... ...
@@ -842,9 +826,8 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
842 826
 			len=msg->via1->i->value.len;
843 827
 			DBG("forward_reply: i=%.*s\n",len, ZSW(s));
844 828
 			if (reverse_hex2int(s, len, (unsigned int*)&dst.id)<0){
845
-				LOG(L_ERR, "ERROR: forward_reply: bad via i param \"%.*s\"\n",
846
-						len, ZSW(s));
847
-					dst.id=0;
829
+				LM_ERR("bad via i param \"%.*s\"\n", len, ZSW(s));
830
+				dst.id=0;
848 831
 			}
849 832
 		}		
850 833
 				
... ...
@@ -862,7 +845,7 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
862 845
 	if(dst.send_sock == NULL) {
863 846
 		dst.send_sock=get_send_socket(msg, &dst.to, dst.proto);
864 847
 		if (dst.send_sock==0){
865
-			LOG(L_ERR, "forward_reply: ERROR: cannot forward reply\n");
848
+			LM_ERR("cannot forward reply\n");
866 849
 			goto done;
867 850
 		}
868 851
 	}