Browse code

cnxcc: Added credit vs cost per second check *before* starting the call

Carlos Ruiz Diaz authored on 12/05/2014 03:08:43
Showing 1 changed files
... ...
@@ -1460,6 +1460,11 @@ static int set_max_credit(struct sip_msg* msg,
1460 1460
 			return -1;
1461 1461
 		}
1462 1462
 
1463
+		if (credit < cost_per_second) {
1464
+			LM_ERR("Not enough credit to start the call: credit=[%f] < cost_per_sec=[%f]", credit, cost_per_second);
1465
+			return -1;
1466
+		}
1467
+
1463 1468
 		if (client_id_val.rs.len == 0 || client_id_val.rs.s == NULL)
1464 1469
 		{
1465 1470
 			LM_ERR("[%.*s]: client ID cannot be null\n", msg->callid->body.len, msg->callid->body.s);