Browse code

sip: insert into blacklist only if default_bl_ttl != 0

Raphael Coeffic authored on 20/11/2013 14:32:53
Showing 1 changed files
... ...
@@ -1290,8 +1290,14 @@ int _trans_layer::send_request(sip_msg* msg, trans_ticket* tt,
1290 1290
     err = p_msg->send(flags);
1291 1291
     if(err < 0){
1292 1292
 	ERROR("Error from transport layer\n");
1293
+
1293 1294
 	delete p_msg;
1294 1295
 	p_msg = NULL;
1296
+
1297
+	if(default_bl_ttl) {
1298
+	    tr_blacklist::instance()->insert(&t->msg->remote_ip,
1299
+					     default_bl_ttl,"503");
1300
+	}
1295 1301
 	tt->_bucket->unlock();
1296 1302
 	goto try_next_dest;
1297 1303
     }
... ...
@@ -1813,8 +1819,10 @@ int _trans_layer::update_uac_reply(trans_bucket* bucket, sip_trans* t, sip_msg*
1813 1819
 	if(reply_code >= 300){
1814 1820
 	
1815 1821
 	    if(reply_code == 503) {
1816
-		tr_blacklist::instance()->insert(&t->msg->remote_ip,
1817
-						 default_bl_ttl,"503");
1822
+		if(default_bl_ttl) {
1823
+		    tr_blacklist::instance()->insert(&t->msg->remote_ip,
1824
+						     default_bl_ttl,"503");
1825
+		}
1818 1826
 		if(!try_next_ip(bucket,t,false))
1819 1827
 		    goto end;
1820 1828
 	    }
... ...
@@ -1929,8 +1937,10 @@ int _trans_layer::update_uac_reply(trans_bucket* bucket, sip_trans* t, sip_msg*
1929 1937
     else { // non-INVITE transaction
1930 1938
 
1931 1939
 	if(reply_code == 503) {
1932
-	    tr_blacklist::instance()->insert(&t->msg->remote_ip,
1933
-					     default_bl_ttl,"503");
1940
+	    if(default_bl_ttl) {
1941
+		tr_blacklist::instance()->insert(&t->msg->remote_ip,
1942
+						 default_bl_ttl,"503");
1943
+	    }
1934 1944
 	    if(!try_next_ip(bucket,t,false))
1935 1945
 		goto end;
1936 1946
 	}
... ...
@@ -2434,9 +2444,11 @@ void _trans_layer::timer_expired(trans_timer* t, trans_bucket* bucket,
2434 2444
 	tr->clear_timer(STIMER_BL);
2435 2445
 	if(!(tr->flags & TR_FLAG_DISABLE_BL)) {
2436 2446
 	    // insert destination to blacklist
2437
-	    tr_blacklist::instance()->insert(&tr->msg->remote_ip,
2438
-					     default_bl_ttl,
2439
-					     "timeout");
2447
+	    if(default_bl_ttl) {
2448
+		tr_blacklist::instance()->insert(&tr->msg->remote_ip,
2449
+						 default_bl_ttl,
2450
+						 "timeout");
2451
+	    }
2440 2452
 	}
2441 2453
 	bucket->remove(tr);
2442 2454
 	break;
... ...
@@ -2673,6 +2685,12 @@ int _trans_layer::try_next_ip(trans_bucket* bucket, sip_trans* tr,
2673 2685
     // and re-send
2674 2686
     if(tr->msg->send(tr->flags) < 0) {
2675 2687
 	ERROR("Error from transport layer\n");
2688
+
2689
+	if(default_bl_ttl) {
2690
+	    tr_blacklist::instance()->insert(&t->msg->remote_ip,
2691
+					     default_bl_ttl,"503");
2692
+	}
2693
+
2676 2694
 	use_new_trans = false;
2677 2695
 	goto try_next_dest;
2678 2696
     }