Skip to content

Commit

Permalink
uac: add uac_inc_cseq function
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Aug 29, 2023
1 parent bc239b1 commit 7962c75
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/uac/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,32 @@ void rr_uac_auth_checker(struct sip_msg *msg, str *r_param, void *cb_param)
return;
}
}

int uac_inc_cseq(struct sip_msg *msg, int val)
{
struct cell *t = uac_tmb.t_gett();
if (t==T_UNDEFINED || t==T_NULL_CELL)
{
LM_CRIT("no current transaction found\n");
return -1;
}

if (apply_cseq_op(msg, val) < 0) {
LM_WARN("Failed to increment the CSEQ header!\n");
return -1;
}

/* only register the TMCB once per transaction */
if (!(msg->msg_flags & FL_USE_UAC_CSEQ ||
t->uas.request->msg_flags & FL_USE_UAC_CSEQ)) {
if (uac_tmb.register_tmcb( msg, 0, TMCB_RESPONSE_FWDED,
apply_cseq_decrement,0,0)!=1) {
LM_ERR("Failed to register TMCB response fwded - continue \n");
return -1;
}
}
msg->msg_flags |= FL_USE_UAC_CSEQ;
t->uas.request->msg_flags |= FL_USE_UAC_CSEQ;

return 1;
}
1 change: 1 addition & 0 deletions modules/uac/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
#include "../rr/api.h"

void rr_uac_auth_checker(struct sip_msg *msg, str *r_param, void *cb_param);
int uac_inc_cseq(struct sip_msg *msg, int val);

#endif
24 changes: 24 additions & 0 deletions modules/uac/doc/uac_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,30 @@ failure_route[check_auth] {
}
...
}
...
</programlisting>
</example>
</section>

<section id="func_uac_inc_cseq" xreflabel="uac_inc_cseq(cseq)">
<title>
<function moreinfo="none">uac_inc_cseq()</function>
</title>
<para>
This function can be called to increase the CSeq of an ongoing request.
</para>
<para>
It receives as the <emphasis>cseq</emphasis> parameter the value that
the CSeq should be incremented with.
</para>
<para>
This function can be used from REQUEST_ROUTE, BRANCH_ROUTE and FAILURE_ROUTE.
</para>
<example>
<title><function>uac_inc_cseq</function> usage</title>
<programlisting format="linespecific">
...
uac_inc_cseq(1);
...
</programlisting>
</example>
Expand Down
12 changes: 12 additions & 0 deletions modules/uac/uac.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static int w_replace_to(struct sip_msg* msg, str* p1, str* p2);
static int w_restore_to(struct sip_msg* msg);

static int w_uac_auth(struct sip_msg* msg, intptr_t _alg);
static int w_uac_inc_cseq(struct sip_msg* msg, int *cseq);
static int fixup_replace_disp_uri(void** param);
static int fixup_free_s(void** param);
static int mod_init(void);
Expand Down Expand Up @@ -112,6 +113,9 @@ static const cmd_export_t cmds[]={
{"uac_auth", (cmd_function)w_uac_auth, {
{CMD_PARAM_STR|CMD_PARAM_OPT,dauth_fixup_algorithms,0}, {0,0,0}},
REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
{"uac_inc_cseq", (cmd_function)w_uac_inc_cseq, {
{CMD_PARAM_INT, 0, 0}, {0,0,0}},
REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
{0,0,{{0,0,0}},0}
};

Expand Down Expand Up @@ -489,3 +493,11 @@ static int w_uac_auth(struct sip_msg* msg, intptr_t _alg)
}


static int w_uac_inc_cseq(struct sip_msg* msg, int *cseq)
{
if (!cseq) {
LM_ERR("scripting bug: uac_inc_cseq() without value!\n");
return E_SCRIPT;
}
return uac_inc_cseq(msg, *cseq);
}

0 comments on commit 7962c75

Please sign in to comment.