Skip to content

Commit

Permalink
[b2b_entities] proper handling of B2B requests without active dialogs
Browse files Browse the repository at this point in the history
If we have a requests that is 100% looking as a B2B related request, but it's not matching any active/ongoing b2b dialog, better reject with 481 and drop instead of pushing it into the script (where may be proxyed).

Closes #3205

(cherry picked from commit caa78d9)
(cherry picked from commit 40b54f3)
  • Loading branch information
bogdan-iancu committed Oct 5, 2023
1 parent e1641a7 commit 2e3a46a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions modules/b2b_entities/dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,25 +984,29 @@ int b2b_prescript_f(struct sip_msg *msg, void *uparam)
&to_tag, &from_tag, &callid);
if(dlg== NULL)
{
LM_DBG("No dialog found\n");
if(method_value != METHOD_ACK)
/* this is a requests which is 100% for the B2B engine, but
* it is not matching any ongoing/active dialogs ->
* -> we should reject with 481 and discard */
LM_DBG("No dialog found, callid= [%.*s], method=%.*s\n",
callid.len, callid.s,msg->first_line.u.request.method.len,
msg->first_line.u.request.method.s);
if(method_value == METHOD_ACK)
{
str ok = str_init("OK");

if(method_value == METHOD_BYE)
tmb.t_reply(msg, 200, &ok);
else
LM_ERR("No dialog found, callid= [%.*s], method=%.*s\n",
callid.len, callid.s,msg->first_line.u.request.method.len,
msg->first_line.u.request.method.s);
} else {
tmb.t_newtran(msg);
tm_tran = tmb.t_gett();
if (tm_tran && tm_tran!=T_UNDEFINED)
tmb.unref_cell(tm_tran);
} else
if(method_value == METHOD_BYE)
{
str ok = str_init("OK");
tmb.t_reply(msg, 200, &ok);
} else {
str ko = str_init("Call/Transaction Does Not Exist");
tmb.t_reply(msg, 481, &ko);
}
lock_release(&table[hash_index].lock);
return SCB_RUN_ALL;
return SCB_DROP_MSG;
}
}

Expand Down

0 comments on commit 2e3a46a

Please sign in to comment.