Skip to content

Commit

Permalink
Merge pull request kamailio#2172 from korayvt/korayvt/dlg_reset_property
Browse files Browse the repository at this point in the history
dialog: add new dlg_reset_property function
  • Loading branch information
miconda authored Dec 9, 2019
2 parents e1a3e0d + 3af08bb commit 0303415
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str *s2);
static int w_dlg_resetflag(struct sip_msg *msg, char *flag, str *s2);
static int w_dlg_setflag(struct sip_msg *msg, char *flag, char *s2);
static int w_dlg_set_property(struct sip_msg *msg, char *prop, char *s2);
static int w_dlg_reset_property(struct sip_msg *msg, char *prop, char *s2);
static int w_dlg_manage(struct sip_msg*, char*, char*);
static int w_dlg_bye(struct sip_msg*, char*, char*);
static int w_dlg_refer(struct sip_msg*, char*, char*);
Expand Down Expand Up @@ -244,6 +245,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"dlg_set_property", (cmd_function)w_dlg_set_property,1,fixup_spve_null,
0, ANY_ROUTE },
{"dlg_reset_property", (cmd_function)w_dlg_reset_property,1,fixup_spve_null,
0, ANY_ROUTE },
{"dlg_remote_profile", (cmd_function)w_dlg_remote_profile, 5, fixup_dlg_remote_profile,
0, ANY_ROUTE },
{"dlg_set_ruri", (cmd_function)w_dlg_set_ruri, 0, NULL,
Expand Down Expand Up @@ -1330,6 +1333,66 @@ static int w_dlg_set_property(struct sip_msg *msg, char *prop, char *s2)
return ki_dlg_set_property(msg, &val);
}

/**
*
*/
static int ki_dlg_reset_property(sip_msg_t *msg, str *pval)
{
dlg_ctx_t *dctx;
dlg_cell_t *d;

if(pval->len<=0) {
LM_ERR("empty property value\n");
return -1;
}
if ( (dctx=dlg_get_dlg_ctx())==NULL )
return -1;

if(pval->len==6 && strncmp(pval->s, "ka-src", 6)==0) {
dctx->iflags &= ~(DLG_IFLAG_KA_SRC);
d = dlg_get_by_iuid(&dctx->iuid);
if(d!=NULL) {
d->iflags &= ~(DLG_IFLAG_KA_SRC);
dlg_release(d);
}
} else if(pval->len==6 && strncmp(pval->s, "ka-dst", 6)==0) {
dctx->iflags &= ~(DLG_IFLAG_KA_DST);
d = dlg_get_by_iuid(&dctx->iuid);
if(d!=NULL) {
d->iflags &= ~(DLG_IFLAG_KA_DST);
dlg_release(d);
}
} else if(pval->len==15 && strncmp(pval->s, "timeout-noreset", 15)==0) {
dctx->iflags &= ~(DLG_IFLAG_TIMER_NORESET);
d = dlg_get_by_iuid(&dctx->iuid);
if(d!=NULL) {
d->iflags &= ~(DLG_IFLAG_TIMER_NORESET);
dlg_release(d);
}
} else {
LM_ERR("unknown property value [%.*s]\n", pval->len, pval->s);
return -1;
}

return 1;
}

/**
*
*/
static int w_dlg_reset_property(struct sip_msg *msg, char *prop, char *s2)
{
str val;

if(fixup_get_svalue(msg, (gparam_t*)prop, &val)!=0)
{
LM_ERR("no property value\n");
return -1;
}

return ki_dlg_reset_property(msg, &val);
}

static int w_dlg_set_timeout_by_profile3(struct sip_msg *msg, char *profile,
char *value, char *timeout_str)
{
Expand Down
42 changes: 42 additions & 0 deletions src/modules/dialog/doc/dialog_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,48 @@ if(has_totag()) {
}
}
...
</programlisting>
</example>
</section>

<section id="dialog.f.dlg_reset_property">
<title>
<function moreinfo="none">dlg_reset_property(attr)</function>
</title>
<para>
Reset a dialog property - an attribute that enable/disable
various behaviours (e.g., sending keep alive requests).
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>attr</emphasis> - name of property. It can be:
<itemizedlist>
<listitem>
'ka-src' - send keep alive OPTION requests to caller
</listitem>
<listitem>
'ka-dst' - send keep alive OPTION requests to callee
</listitem>
<listitem>
'timeout-noreset' - don't reset timeout on in-dialog messages reception
</listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>dlg_reset_property</function> usage</title>
<programlisting format="linespecific">
...
dlg_reset_property("ka-src");
dlg_reset_property("ka-dst");
dlg_reset_property("timeout-noreset");
...

</programlisting>
</example>
</section>
Expand Down

0 comments on commit 0303415

Please sign in to comment.