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 217
 	}
218 218
 	return si;
219 219
 error:
220
-	LOG(L_ERR, "ERROR: get_out_socket: no socket found\n");
220
+	LM_ERR("no socket found\n");
221 221
 	ERR("no corresponding socket found for(%s:%s)\n",
222 222
 			proto2a(proto), su2a(to, sizeof(*to)));
223 223
 	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 264
 											proto);
265 265
 			if (unlikely(force_send_socket == 0)){
266 266
 				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",
267
+				LM_WARN("protocol/port mismatch (forced %s:%s:%d, to %s:%s)\n",
270 268
 						proto2a(orig->proto), ip_addr2a(&orig->address),
271 269
 						orig->port_no,
272 270
 						proto2a(proto), su2a(to, sizeof(*to)));
... ...
@@ -297,8 +293,7 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
297 297
 				return force_send_socket;
298 298
 		else{
299 299
 			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),"
300
+				LM_WARN("not listening on the requested socket (%s:%s:%d),"
302 301
 							 " no fork mode?\n",
303 302
 							proto2a(force_send_socket->proto),
304 303
 							ip_addr2a(&force_send_socket->address),
... ...
@@ -312,7 +307,7 @@ not_forced:
312 312
 		if ((send_sock==0) || (send_sock->socket!=-1))
313 313
 			return send_sock; /* found or error*/
314 314
 		else if (send_sock->socket==-1){
315
-			LOG(L_WARN, "WARNING: get_send_socket: not listening on the"
315
+			LM_WARN("not listening on the"
316 316
 					" requested socket (%s:%s:%d), no fork mode?\n",
317 317
 					proto2a(send_sock->proto), ip_addr2a(&send_sock->address),
318 318
 					send_sock->port_no);
... ...
@@ -336,8 +331,8 @@ not_forced:
336 336
 								break;
337 337
 				case AF_INET6:	send_sock=sendipv6_tcp;
338 338
 								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);
339
+				default:	LM_ERR("don't know how to forward to af %d\n",
340
+									to->s.sa_family);
341 341
 			}
342 342
 			break;
343 343
 #endif
... ...
@@ -350,8 +345,8 @@ not_forced:
350 350
 								break;
351 351
 				case AF_INET6:	send_sock=sendipv6_tls;
352 352
 								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);
353
+				default:	LM_ERR("don't know how to forward to af %d\n",
354
+									to->s.sa_family);
355 355
 			}
356 356
 			break;
357 357
 #endif /* USE_TLS */
... ...
@@ -365,8 +360,7 @@ not_forced:
365 365
 									break;
366 366
 					case AF_INET6:	send_sock=sendipv6_sctp;
367 367
 									break;
368
-					default:	LOG(L_ERR, "get_send_socket: BUG: don't know"
369
-										" how to forward to af %d\n",
368
+					default:	LM_ERR("don't know how to forward to af %d\n",
370 369
 										to->s.sa_family);
371 370
 				}
372 371
 			}else send_sock=bind_address;
... ...
@@ -381,15 +375,13 @@ not_forced:
381 381
 									break;
382 382
 					case AF_INET6:	send_sock=sendipv6;
383 383
 									break;
384
-					default:	LOG(L_ERR, "get_send_socket: BUG: don't know"
385
-										" how to forward to af %d\n",
384
+					default:	LM_ERR("don't know how to forward to af %d\n",
386 385
 										to->s.sa_family);
387 386
 				}
388 387
 			}else send_sock=bind_address;
389 388
 			break;
390 389
 		default:
391
-			LOG(L_CRIT, "BUG: get_send_socket: unsupported proto %d (%s)\n",
392
-					proto, proto2a(proto));
390
+			LM_CRIT("unsupported proto %d (%s)\n", proto, proto2a(proto));
393 391
 	}
394 392
 	return send_sock;
395 393
 }
... ...
@@ -528,17 +520,15 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
528 528
 			err=dns_sip_resolve2su(&dns_srv_h, &send_info->to, dst, port,
529 529
 									&proto, dns_flags);
530 530
 			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);
531
+				LM_ERR("resolving \"%.*s\" failed: %s [%d]\n",
532
+						dst->len, ZSW(dst->s), dns_strerror(err), err);
534 533
 				ret=E_BAD_ADDRESS;
535 534
 				goto error;
536 535
 			}
537 536
 		}else
538 537
 #endif
539 538
 		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));
539
+			LM_ERR("bad host name %.*s, dropping packet\n", dst->len, ZSW(dst->s));
542 540
 			ret=E_BAD_ADDRESS;
543 541
 			goto error;
544 542
 		}
... ...
@@ -551,14 +541,14 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
551 551
 	   with the same branch parameter and will be match-able downstream
552 552
 	*/
553 553
 	if (!char_msg_val( msg, md5 )) 	{ /* parses transaction key */
554
-		LOG(L_ERR, "ERROR: forward_request: char_msg_val failed\n");
554
+		LM_ERR("char_msg_val failed\n");
555 555
 		ret=E_UNSPEC;
556 556
 		goto error;
557 557
 	}
558 558
 	msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number);
559 559
 	if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */,
560 560
 				msg->add_to_branch_s, &msg->add_to_branch_len )) {
561
-		LOG(L_ERR, "ERROR: forward_request: branch_builder failed\n");
561
+		LM_ERR("branch_builder failed\n");
562 562
 		ret=E_UNSPEC;
563 563
 		goto error;
564 564
 	}
... ...
@@ -570,7 +560,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
570 570
 		if (orig_send_sock==0) /* no forced send_sock => find it **/
571 571
 			send_info->send_sock=get_send_socket(msg, &send_info->to, proto);
572 572
 		if (send_info->send_sock==0){
573
-			LOG(L_ERR, "forward_req: ERROR: cannot forward to af %d, proto %d "
573
+			LM_ERR("cannot forward to af %d, proto %d "
574 574
 						"no corresponding listening socket\n",
575 575
 						send_info->to.s.sa_family, proto);
576 576
 			ret=ser_error=E_NO_SOCKET;
... ...
@@ -591,7 +581,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
591 591
 			send_info->proto=proto;
592 592
 			buf = build_req_buf_from_sip_req(msg, &len, send_info, 0);
593 593
 			if (!buf){
594
-				LOG(L_ERR, "ERROR: forward_request: building failed\n");
594
+				LM_ERR("building failed\n");
595 595
 				ret=E_OUT_OF_MEM; /* most probable */
596 596
 				goto error;
597 597
 			}
... ...
@@ -605,9 +595,8 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
605 605
 	
606 606
 		if (run_onsend(msg, send_info, buf, len)==0){
607 607
 			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);
608
+			LM_INFO("request to %s:%d(%d) dropped (onsend_route)\n",
609
+				ip_addr2a(&ip), su_getport(&send_info->to), send_info->proto);
611 610
 			ser_error=E_OK; /* no error */
612 611
 			ret=E_ADM_PROHIBITED;
613 612
 #ifdef USE_DNS_FAILOVER
... ...
@@ -620,9 +609,8 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
620 620
 		if (cfg_get(core, core_cfg, use_dst_blacklist)){
621 621
 			if (dst_is_blacklisted(send_info, msg)){
622 622
 				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);
623
+				LM_DBG("blacklisted destination:%s:%d (%d)\n",
624
+					ip_addr2a(&ip), su_getport(&send_info->to), send_info->proto);
626 625
 				ret=ser_error=E_SEND;
627 626
 #ifdef USE_DNS_FAILOVER
628 627
 				continue; /* try another ip */
... ...
@@ -667,8 +655,7 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
667 667
 			((err=dns_sip_resolve2su(&dns_srv_h, &send_info->to, dst, port,
668 668
 										&proto, dns_flags))==0));
669 669
 	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",
670
+		LM_ERR("resolving %.*s host name in uri failed: %s [%d] (dropping packet)\n",
672 671
 									dst->len, ZSW(dst->s),
673 672
 									dns_strerror(err), err);
674 673
 		ret=ser_error=E_BAD_ADDRESS;
... ...
@@ -723,7 +710,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
723 723
 			DBG("update_sock_struct_from_via: using 'rport'\n");
724 724
 			port=str2s(via->rport->value.s, via->rport->value.len, &err);
725 725
 			if (err){
726
-				LOG(L_NOTICE, "ERROR: update_sock_struct_from_via: bad rport value(%.*s)\n",
726
+				LM_ERR("bad rport value(%.*s)\n",
727 727
 						via->rport->value.len, via->rport->value.s);
728 728
 				port=0;
729 729
 			}
... ...
@@ -753,9 +740,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
753 753
 	he=sip_resolvehost(name, &port, &proto);
754 754
 	
755 755
 	if (he==0){
756
-		LOG(L_NOTICE,
757
-				"update_sock_struct_from_via:resolve_host(%.*s) failure\n",
758
-				name->len, name->s);
756
+		LM_NOTICE("resolve_host(%.*s) failure\n", name->len, name->s);
759 757
 		return -1;
760 758
 	}
761 759
 		
... ...
@@ -784,9 +769,8 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
784 784
 		if (check_self(&msg->via1->host,
785 785
 					msg->via1->port?msg->via1->port:SIP_PORT,
786 786
 					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);
787
+			LM_ERR("host in first via!=me : %.*s:%d\n",
788
+				msg->via1->host.len, msg->via1->host.s, msg->via1->port);
790 789
 			/* send error msg back? */
791 790
 			goto error;
792 791
 		}
... ...
@@ -802,13 +786,13 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
802 802
 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
803 803
 	{
804 804
 		/* no second via => error */
805
-		LOG(L_DBG, "reply cannot be forwarded - no 2nd via\n");
805
+		LM_DBG("reply cannot be forwarded - no 2nd via\n");
806 806
 		goto error;
807 807
 	}
808 808
 
809 809
 	new_buf = build_res_buf_from_sip_res( msg, &new_len);
810 810
 	if (!new_buf){
811
-		LOG(L_ERR, "ERROR: forward_reply: building failed\n");
811
+		LM_ERR("building failed\n");
812 812
 		goto error;
813 813
 	}
814 814
 
... ...
@@ -842,9 +826,8 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
842 842
 			len=msg->via1->i->value.len;
843 843
 			DBG("forward_reply: i=%.*s\n",len, ZSW(s));
844 844
 			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;
845
+				LM_ERR("bad via i param \"%.*s\"\n", len, ZSW(s));
846
+				dst.id=0;
848 847
 			}
849 848
 		}		
850 849
 				
... ...
@@ -862,7 +845,7 @@ static int do_forward_reply(struct sip_msg* msg, int mode)
862 862
 	if(dst.send_sock == NULL) {
863 863
 		dst.send_sock=get_send_socket(msg, &dst.to, dst.proto);
864 864
 		if (dst.send_sock==0){
865
-			LOG(L_ERR, "forward_reply: ERROR: cannot forward reply\n");
865
+			LM_ERR("cannot forward reply\n");
866 866
 			goto done;
867 867
 		}
868 868
 	}