Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strans/accept: fix cancel/rejection #423

Merged
merged 4 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/sipsess/accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ int sipsess_answer(struct sipsess *sess, uint16_t scode, const char *reason,
va_list ap;
int err;

if (!sess || (!sess->st
&& (sess->established || sess->awaiting_answer))
|| !sess->msg || scode < 200 || scode > 299)
if (!sess || !sess->st || !sess->msg || scode < 200 || scode > 299)
return EINVAL;

va_start(ap, fmt);
Expand Down
10 changes: 7 additions & 3 deletions src/sipsess/reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int sipsess_reply_2xx(struct sipsess *sess, const struct sip_msg *msg,
{
struct sipsess_reply *reply;
struct sip_contact contact;
bool is_prack = false;
int err = ENOMEM;

reply = mem_zalloc(sizeof(*reply), destructor);
Expand All @@ -101,9 +102,10 @@ int sipsess_reply_2xx(struct sipsess *sess, const struct sip_msg *msg,
reply->msg = mem_ref((void *)msg);
reply->sess = sess;

is_prack = !pl_strcmp(&msg->met, "PRACK");
sip_contact_set(&contact, sess->cuser, &msg->dst, msg->tp);

err = sip_treplyf(&sess->st, &reply->mb, sess->sip,
err = sip_treplyf(is_prack ? NULL : &sess->st, &reply->mb, sess->sip,
maximilianfridrich marked this conversation as resolved.
Show resolved Hide resolved
msg, true, scode, reason,
"%H"
"%v"
Expand All @@ -123,7 +125,7 @@ int sipsess_reply_2xx(struct sipsess *sess, const struct sip_msg *msg,
if (err)
goto out;

if (pl_strcmp(&msg->met, "PRACK")) {
if (!is_prack) {
tmr_start(&reply->tmr, 64 * SIP_T1, tmr_handler, reply);
tmr_start(&reply->tmrg, SIP_T1, retransmit_handler, reply);
}
Expand All @@ -138,7 +140,9 @@ int sipsess_reply_2xx(struct sipsess *sess, const struct sip_msg *msg,

out:
if (err) {
sess->st = mem_deref(sess->st);
if (!is_prack)
Fixed Show fixed Hide fixed
sess->st = mem_deref(sess->st);

mem_deref(reply);
}

Expand Down