[sr-dev] git:master:fb8cc72f: cnxcc: avoid duplicated call info

Victor Seva linuxmaniac at torreviejawireless.org
Thu Jul 2 16:31:31 CEST 2020


Module: kamailio
Branch: master
Commit: fb8cc72f1bd76bb2fd4d4e2e5fa2afc50eef59ad
URL: https://github.com/kamailio/kamailio/commit/fb8cc72f1bd76bb2fd4d4e2e5fa2afc50eef59ad

Author: Jose Luis Verdeguer <pepeluxx at gmail.com>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2020-07-02T16:30:22+02:00

cnxcc: avoid duplicated call info

Don't store call if call-id is already registered for that client

---

Modified: src/modules/cnxcc/cnxcc_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/fb8cc72f1bd76bb2fd4d4e2e5fa2afc50eef59ad.diff
Patch: https://github.com/kamailio/kamailio/commit/fb8cc72f1bd76bb2fd4d4e2e5fa2afc50eef59ad.patch

---

diff --git a/src/modules/cnxcc/cnxcc_mod.c b/src/modules/cnxcc/cnxcc_mod.c
index c2b6c1f567..e84d63acff 100644
--- a/src/modules/cnxcc/cnxcc_mod.c
+++ b/src/modules/cnxcc/cnxcc_mod.c
@@ -1488,6 +1488,7 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient, str *scredit,
 {
 	credit_data_t *credit_data = NULL;
 	call_t *call = NULL;
+	hash_tables_t *hts = NULL;
 
 	double credit = 0, connect_cost = 0, cost_per_second = 0;
 
@@ -1529,6 +1530,12 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient, str *scredit,
 		return -1;
 	}
 
+	if(try_get_call_entry(&msg->callid->body, &call, &hts) == 0) {
+		LM_ERR("call-id[%.*s] already present\n",
+		msg->callid->body.len, msg->callid->body.s);
+		return -4;
+	}
+
 	LM_DBG("Setting up new call for client [%.*s], max-credit[%f], "
 		   "connect-cost[%f], cost-per-sec[%f], initial-pulse [%d], "
 		   "final-pulse [%d], call-id[%.*s]\n",
@@ -1706,6 +1713,7 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
 {
 	credit_data_t *credit_data = NULL;
 	call_t *call = NULL;
+	hash_tables_t *hts = NULL;
 
 	if(parse_headers(msg, HDR_CALLID_F, 0) != 0) {
 		LM_ERR("Error parsing Call-ID");
@@ -1736,6 +1744,12 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
 		return -1;
 	}
 
+	if(try_get_call_entry(&msg->callid->body, &call, &hts) == 0) {
+		LM_ERR("call-id[%.*s] already present\n",
+		msg->callid->body.len, msg->callid->body.s);
+		return -4;
+	}
+
 	LM_DBG("Setting up new call for client [%.*s], max-chan[%d], "
 		   "call-id[%.*s]\n",
 			sclient->len, sclient->s, max_chan, msg->callid->body.len,
@@ -1792,6 +1806,7 @@ static int ki_set_max_time(sip_msg_t *msg, str *sclient, int max_secs)
 {
 	credit_data_t *credit_data = NULL;
 	call_t *call = NULL;
+	hash_tables_t *hts = NULL;
 
 	if(parse_headers(msg, HDR_CALLID_F, 0) != 0) {
 		LM_ERR("Error parsing Call-ID");
@@ -1823,6 +1838,12 @@ static int ki_set_max_time(sip_msg_t *msg, str *sclient, int max_secs)
 		return -1;
 	}
 
+	if(try_get_call_entry(&msg->callid->body, &call, &hts) == 0) {
+		LM_ERR("call-id[%.*s] already present\n",
+		msg->callid->body.len, msg->callid->body.s);
+		return -4;
+	}
+
 	LM_DBG("Setting up new call for client [%.*s], max-secs[%d], "
 		   "call-id[%.*s]\n",
 			sclient->len, sclient->s, max_secs, msg->callid->body.len,




More information about the sr-dev mailing list