Skip to content

Commit

Permalink
cnxcc: avoid duplicated call info
Browse files Browse the repository at this point in the history
Don't store call if call-id is already registered for that client
  • Loading branch information
Pepelux authored and linuxmaniac committed Jul 2, 2020
1 parent 4cb61cc commit fb8cc72
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/modules/cnxcc/cnxcc_mod.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fb8cc72

Please sign in to comment.