Browse code

resolve.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 04/10/2014 01:08:14
Showing 1 changed files
... ...
@@ -151,8 +151,7 @@ static on_resolv_reinit	on_resolv_reinit_cb = NULL;
151 151
 int register_resolv_reinit_cb(on_resolv_reinit cb)
152 152
 {
153 153
 	if (on_resolv_reinit_cb) {
154
-		LOG(L_ERR, "ERROR: register_resolv_reinit_cb(): "
155
-			"callback function has been already registered\n");
154
+		LM_ERR("callback function has been already registered\n");
156 155
 		return -1;
157 156
 	}
158 157
 	on_resolv_reinit_cb = cb;
... ...
@@ -201,8 +200,7 @@ static int _resolv_init(void)
201 201
 		_res.options&=~(RES_DEFNAMES|RES_DNSRCH);
202 202
 #else
203 203
 #warning "no resolv timeout support"
204
-	LOG(L_WARN, "WARNING: _resolv_init: no resolv options support - resolv"
205
-			" options will be ignored\n");
204
+	LM_WARN("no resolv options support - resolv options will be ignored\n");
206 205
 #endif
207 206
 	return 0;
208 207
 }
... ...
@@ -232,8 +230,7 @@ void resolv_reinit(str *gname, str *name)
232 232
 #ifdef DNS_WATCHDOG_SUPPORT
233 233
 	if (on_resolv_reinit_cb) on_resolv_reinit_cb(name);
234 234
 #endif
235
-	LOG(L_DBG, "DEBUG: resolv_reinit(): "
236
-		"DNS resolver has been reinitialized\n");
235
+	LM_DBG("DNS resolver has been reinitialized\n");
237 236
 }
238 237
 
239 238
 /* fixup function for dns_reinit variable
... ...
@@ -260,8 +257,7 @@ void reinit_proto_prefs(str *gname, str *name)
260 260
 int dns_try_ipv6_fixup(void *handle, str *gname, str *name, void **val)
261 261
 {
262 262
 	if ((int)(long)(*val) && !(socket_types & SOCKET_T_IPV6)) {
263
-		LOG(L_ERR, "ERROR: dns_try_ipv6_fixup(): "
264
-			"SER does not listen on any ipv6 interface, "
263
+		LM_ERR("SER does not listen on any ipv6 interface, "
265 264
 			"there is no point in resolving ipv6 addresses\n");
266 265
 		return -1;
267 266
 	}
... ...
@@ -341,7 +337,7 @@ struct srv_rdata* dns_srv_parser( unsigned char* msg, unsigned char* end,
341 341
 	/* alloc enought space for the struct + null terminated name */
342 342
 	srv=local_malloc(sizeof(struct srv_rdata)-1+len+1);
343 343
 	if (srv==0){
344
-		LOG(L_ERR, "ERROR: dns_srv_parser: out of memory\n");
344
+		LM_ERR("out of memory\n");
345 345
 		goto error;
346 346
 	}
347 347
 	srv->priority=ntohs(priority);
... ...
@@ -427,7 +423,7 @@ struct naptr_rdata* dns_naptr_parser( unsigned char* msg, unsigned char* end,
427 427
 	naptr=local_malloc(sizeof(struct naptr_rdata)+flags_len+services_len+
428 428
 						regexp_len+len+1-1);
429 429
 	if (naptr == 0){
430
-		LOG(L_ERR, "ERROR: dns_naptr_parser: out of memory\n");
430
+		LM_ERR("out of memory\n");
431 431
 		goto error;
432 432
 	}
433 433
 	naptr->order=ntohs(order);
... ...
@@ -472,7 +468,7 @@ struct cname_rdata* dns_cname_parser( unsigned char* msg, unsigned char* end,
472 472
 	/* alloc sizeof struct + space for the null terminated name */
473 473
 	cname=local_malloc(sizeof(struct cname_rdata)-1+len+1);
474 474
 	if(cname==0){
475
-		LOG(L_ERR, "ERROR: dns_cname_parser: out of memory\n");
475
+		LM_ERR("out of memory\n");
476 476
 		goto error;
477 477
 	}
478 478
 	cname->name_len=len;
... ...
@@ -496,7 +492,7 @@ struct a_rdata* dns_a_parser(unsigned char* rdata, unsigned char* eor)
496 496
 	if (rdata+4>eor) goto error;
497 497
 	a=(struct a_rdata*)local_malloc(sizeof(struct a_rdata));
498 498
 	if (a==0){
499
-		LOG(L_ERR, "ERROR: dns_a_parser: out of memory\n");
499
+		LM_ERR("out of memory\n");
500 500
 		goto error;
501 501
 	}
502 502
 	memcpy(a->ip, rdata, 4);
... ...
@@ -516,7 +512,7 @@ struct aaaa_rdata* dns_aaaa_parser(unsigned char* rdata, unsigned char* eor)
516 516
 	if (rdata+16>eor) goto error;
517 517
 	aaaa=(struct aaaa_rdata*)local_malloc(sizeof(struct aaaa_rdata));
518 518
 	if (aaaa==0){
519
-		LOG(L_ERR, "ERROR: dns_aaaa_parser: out of memory\n");
519
+		LM_ERR("out of memory\n");
520 520
 		goto error;
521 521
 	}
522 522
 	memcpy(aaaa->ip6, rdata, 16);
... ...
@@ -567,7 +563,7 @@ static struct txt_rdata* dns_txt_parser(unsigned char* msg, unsigned char* end,
567 567
 	txt=local_malloc(sizeof(struct txt_rdata) +(n-1)*sizeof(struct dns_cstr)+
568 568
 						str_size);
569 569
 	if(unlikely(txt==0)){
570
-		LOG(L_ERR, "ERROR: dns_txt_parser: out of memory\n");
570
+		LM_ERR("out of memory\n");
571 571
 		goto error;
572 572
 	}
573 573
 	/* string table */
... ...
@@ -637,7 +633,7 @@ static struct ebl_rdata* dns_ebl_parser(unsigned char* msg, unsigned char* end,
637 637
 	/* alloc sizeof struct + space for the 2 null-terminated strings */
638 638
 	ebl=local_malloc(sizeof(struct ebl_rdata)-1+sep_len+1+apex_len+1);
639 639
 	if (ebl==0){
640
-		LOG(L_ERR, "ERROR: dns_ebl_parser: out of memory\n");
640
+		LM_ERR("out of memory\n");
641 641
 		goto error;
642 642
 	}
643 643
 	ebl->position=rdata[0];
... ...
@@ -675,7 +671,7 @@ struct ptr_rdata* dns_ptr_parser( unsigned char* msg, unsigned char* end,
675 675
 	/* alloc sizeof struct + space for the null terminated name */
676 676
 	pname=local_malloc(sizeof(struct ptr_rdata)-1+len+1);
677 677
 	if(pname==0){
678
-		LOG(L_ERR, "ERROR: dns_ptr_parser: out of memory\n");
678
+		LM_ERR("out of memory\n");
679 679
 		goto error;
680 680
 	}
681 681
 	pname->ptrdname_len=len;
... ...
@@ -786,7 +782,7 @@ struct rdata* get_record(char* name, int type, int flags)
786 786
 	for (r=0; r<qno; r++){
787 787
 		/* skip the name of the question */
788 788
 		if (unlikely((p=dns_skipname(p, end))==0)) {
789
-			LOG(L_ERR, "ERROR: get_record: skipname==0\n");
789
+			LM_ERR("skipname==0\n");
790 790
 			goto error;
791 791
 		}
792 792
 		p+=2+2; /* skip QCODE & QCLASS */
... ...
@@ -795,7 +791,7 @@ struct rdata* get_record(char* name, int type, int flags)
795 795
 		p+=1+2+2; /* skip the ending  '\0, QCODE and QCLASS */
796 796
 	#endif
797 797
 		if (unlikely(p>end)) {
798
-			LOG(L_ERR, "ERROR: get_record: p>=end\n");
798
+			LM_ERR("p>=end\n");
799 799
 			goto error;
800 800
 		}
801 801
 	};
... ...
@@ -805,21 +801,21 @@ again:
805 805
 #if 0
806 806
 		/*  ignore it the default domain name */
807 807
 		if ((p=dns_skipname(p, end))==0) {
808
-			LOG(L_ERR, "ERROR: get_record: skip_name=0 (#2)\n");
808
+			LM_ERR("get_record: skip_name=0 (#2)\n");
809 809
 			goto error;
810 810
 		}
811 811
 #else
812 812
 		if (unlikely((skip=dn_expand(buff.buff, end, p, rec_name,
813 813
 							MAX_DNS_NAME-1))==-1)){
814
-			LOG(L_ERR, "ERROR: get_record: dn_expand(rec_name) failed\n");
814
+			LM_ERR("dn_expand(rec_name) failed\n");
815 815
 			goto error;
816 816
 		}
817 817
 #endif
818 818
 		p+=skip;
819 819
 		rec_name_len=strlen(rec_name);
820 820
 		if (unlikely(rec_name_len>255)){
821
-			LOG(L_ERR, "ERROR: get_record: dn_expand(rec_name): name too"
822
-					" long  (%d)\n", rec_name_len);
821
+			LM_ERR("dn_expand(rec_name): name too long (%d)\n",
822
+					rec_name_len);
823 823
 			goto error;
824 824
 		}
825 825
 		/* check if enough space is left for type, class, ttl & size */
... ...
@@ -852,7 +848,7 @@ again:
852 852
 		rd=(struct rdata*) local_malloc(sizeof(struct rdata)+rec_name_len+
853 853
 										1-1);
854 854
 		if (rd==0){
855
-			LOG(L_ERR, "ERROR: get_record: out of memory\n");
855
+			LM_ERR("out of memory\n");
856 856
 			goto error;
857 857
 		}
858 858
 		rd->type=rtype;
... ...
@@ -954,7 +950,7 @@ again:
954 954
 				last=&(rd->next);
955 955
 				break;
956 956
 			default:
957
-				LOG(L_ERR, "WARNING: get_record: unknown type %d\n", rtype);
957
+				LM_ERR("unknown type %d\n", rtype);
958 958
 				rd->rdata=0;
959 959
 				*last=rd;
960 960
 				last=&(rd->next);
... ...
@@ -973,7 +969,7 @@ again:
973 973
 		for (r=0; (r<answers_no) && (p<end); r++){
974 974
 			/* skip over the ns records */
975 975
 			if ((p=dns_skipname(p, end))==0) {
976
-				LOG(L_ERR, "ERROR: get_record: skip_name=0 (#3)\n");
976
+				LM_ERR("skip_name=0 (#3)\n");
977 977
 				goto error;
978 978
 			}
979 979
 			/* check if enough space is left for type, class, ttl & size */
... ...
@@ -996,7 +992,7 @@ again:
996 996
 	if ((search_list_used==1)&&(fullname_rd!=0)) {
997 997
 		rd=(struct rdata*) local_malloc(sizeof(struct rdata)+name_len+1-1);
998 998
 		if (unlikely(rd==0)){
999
-			LOG(L_ERR, "ERROR: get_record: out of memory\n");
999
+			LM_ERR("out of memory\n");
1000 1000
 			goto error;
1001 1001
 		}
1002 1002
 		rd->type=T_CNAME;
... ...
@@ -1010,7 +1006,7 @@ again:
1010 1010
 		rd->rdata=(void*)local_malloc(sizeof(struct cname_rdata)-1+
1011 1011
 										head->name_len+1);
1012 1012
 		if(unlikely(rd->rdata==0)){
1013
-			LOG(L_ERR, "ERROR: get_record: out of memory\n");
1013
+			LM_ERR("out of memory\n");
1014 1014
 			goto error_rd;
1015 1015
 		}
1016 1016
 		((struct cname_rdata*)(rd->rdata))->name_len=fullname_rd->name_len;
... ...
@@ -1022,19 +1018,19 @@ again:
1022 1022
 
1023 1023
 	return head;
1024 1024
 error_boundary:
1025
-		LOG(L_ERR, "ERROR: get_record: end of query buff reached\n");
1025
+		LM_ERR("end of query buff reached\n");
1026 1026
 		if (head) free_rdata_list(head);
1027 1027
 		return 0;
1028 1028
 error_parse:
1029
-		LOG(L_ERR, "ERROR: get_record: rdata parse error (%s, %d), %p-%p"
1030
-						" rtype=%d, class=%d, ttl=%d, rdlength=%d \n",
1029
+		LM_ERR("rdata parse error (%s, %d), %p-%p"
1030
+				" rtype=%d, class=%d, ttl=%d, rdlength=%d\n",
1031 1031
 				name, type,
1032 1032
 				p, end, rtype, class, ttl, rdlength);
1033 1033
 error_rd:
1034 1034
 		if (rd) local_free(rd); /* rd->rdata=0 & rd is not linked yet into
1035 1035
 								   the list */
1036 1036
 error:
1037
-		LOG(L_ERR, "ERROR: get_record \n");
1037
+		LM_ERR("get_record\n");
1038 1038
 		if (head) free_rdata_list(head);
1039 1039
 not_found:
1040 1040
 	/* increment error counter */
... ...
@@ -1234,7 +1230,7 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned short* port,
1234 1234
 	srv_head=0;
1235 1235
 	srv_target=0;
1236 1236
 	if (name->len >= MAX_DNS_NAME) {
1237
-		LOG(L_ERR, "srv_sip_resolvehost: domain name too long\n");
1237
+		LM_ERR("domain name too long\n");
1238 1238
 		he=0;
1239 1239
 		goto end;
1240 1240
 	}
... ...
@@ -1277,8 +1273,8 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned short* port,
1277 1277
 			goto end;
1278 1278
 		}
1279 1279
 		if ((name->len+SRV_MAX_PREFIX_LEN+1)>MAX_DNS_NAME){
1280
-			LOG(L_WARN, "WARNING: srv_sip_resolvehost: domain name too long (%d),"
1281
-						" unable to perform SRV lookup\n", name->len);
1280
+			LM_WARN("domain name too long (%d), unable to perform SRV lookup\n",
1281
+						name->len);
1282 1282
 		}else{
1283 1283
 			
1284 1284
 			switch(srv_proto){
... ...
@@ -1289,8 +1285,7 @@ struct hostent* srv_sip_resolvehost(str* name, int zt, unsigned short* port,
1289 1289
 					create_srv_name(srv_proto, name, tmp);
1290 1290
 					break;
1291 1291
 				default:
1292
-					LOG(L_CRIT, "BUG: srv_sip_resolvehost: unknown proto %d\n",
1293
-							srv_proto);
1292
+					LM_CRIT("unknown proto %d\n", srv_proto);
1294 1293
 					he=0;
1295 1294
 					goto end;
1296 1295
 			}
... ...
@@ -1301,7 +1296,7 @@ do_srv:
1301 1301
 				if (l->type!=T_SRV) continue; 
1302 1302
 				srv=(struct srv_rdata*) l->rdata;
1303 1303
 				if (srv==0){
1304
-					LOG(L_CRIT, "srv_sip_resolvehost: BUG: null rdata\n");
1304
+					LM_CRIT("null rdata\n");
1305 1305
 					/* cleanup on exit only */
1306 1306
 					break;
1307 1307
 				}
... ...
@@ -1322,7 +1317,7 @@ do_srv:
1322 1322
 				if (l->type!=T_SRV) continue; /*should never happen*/
1323 1323
 				srv=(struct srv_rdata*) l->rdata;
1324 1324
 				if (srv==0){
1325
-					LOG(L_CRIT, "srv_sip_resolvehost: BUG: null rdata\n");
1325
+					LM_CRIT("null rdata\n");
1326 1326
 					/* cleanup on exit only */
1327 1327
 					break;
1328 1328
 				}
... ...
@@ -1412,7 +1407,7 @@ struct rdata* naptr_sip_iterate(struct rdata* naptr_head,
1412 1412
 		if (l->type!=T_NAPTR) continue; 
1413 1413
 		naptr=(struct naptr_rdata*) l->rdata;
1414 1414
 		if (naptr==0){
1415
-				LOG(L_CRIT, "naptr_iterate: BUG: null rdata\n");
1415
+			LM_CRIT("null rdata\n");
1416 1416
 			goto end;
1417 1417
 		}
1418 1418
 		/* check if valid and get proto */
... ...
@@ -1475,7 +1470,7 @@ void create_srv_name(char proto, str *name, char *srv) {
1475 1475
 			srv[SRV_SCTP_PREFIX_LEN + name->len] = '\0';
1476 1476
 			break;
1477 1477
 		default:
1478
-			LOG(L_CRIT, "BUG: %s: unknown proto %d\n", __func__, proto);
1478
+			LM_CRIT("%s: unknown proto %d\n", __func__, proto);
1479 1479
 	}
1480 1480
 }
1481 1481
 
... ...
@@ -1568,8 +1563,7 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned short* port, ch
1568 1568
 	}
1569 1569
 
1570 1570
 	if ((name->len+SRV_MAX_PREFIX_LEN+1)>MAX_DNS_NAME){
1571
-		LOG(L_WARN, "WARNING: no_naptr_srv_sip_resolvehost: domain name too long"
1572
-						" (%d), unable to perform SRV lookup\n", name->len);
1571
+		LM_WARN("domain name too long (%d), unable to perform SRV lookup\n", name->len);
1573 1572
 	} else {
1574 1573
 		/* looping on the ordered list until we found a protocol what has srv record */
1575 1574
 		list_len = create_srv_pref_list(proto, srv_proto_list);
... ...
@@ -1582,8 +1576,7 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned short* port, ch
1582 1582
 					create_srv_name(srv_proto_list[i].proto, name, tmp_srv);
1583 1583
 					break;
1584 1584
 				default:
1585
-					LOG(L_CRIT, "BUG: no_naptr_srv_sip_resolvehost: unknown proto %d\n",
1586
-							(int)srv_proto_list[i].proto);
1585
+					LM_CRIT("unknown proto %d\n", (int)srv_proto_list[i].proto);
1587 1586
 					return 0;
1588 1587
 			}
1589 1588
 			/* set default port */
... ...
@@ -1640,7 +1633,7 @@ struct hostent* naptr_sip_resolvehost(str* name,  unsigned short* port,
1640 1640
 	naptr_head=0;
1641 1641
 	he=0;
1642 1642
 	if (name->len >= MAX_DNS_NAME) {
1643
-		LOG(L_ERR, "naptr_sip_resolvehost: domain name too long\n");
1643
+		LM_ERR("domain name too long\n");
1644 1644
 		goto end;
1645 1645
 	}
1646 1646
 	/* try NAPTR if no port or protocol is specified and NAPTR lookup is
... ...
@@ -1729,8 +1722,8 @@ int sip_hostport2su(union sockaddr_union* su, str* name, unsigned short port,
1729 1729
 	he=sip_resolvehost(name, &port, proto);
1730 1730
 	if (he==0){
1731 1731
 		ser_error=E_BAD_ADDRESS;
1732
-		LOG(L_ERR, "ERROR: sip_hostport2su: could not resolve hostname:"
1733
-					" \"%.*s\"\n", name->len, name->s);
1732
+		LM_ERR("could not resolve hostname: \"%.*s\"\n",
1733
+					name->len, name->s);
1734 1734
 		goto error;
1735 1735
 	}
1736 1736
 	/* port filled by sip_resolvehost if empty*/