Skip to content

Commit

Permalink
Merge pull request #3277 from smititelu/master
Browse files Browse the repository at this point in the history
dialog: add one more param to dlg_send_sequential mi function
  • Loading branch information
razvancrainea committed Jan 5, 2024
2 parents 1d712c1 + 48bbd31 commit 953d138
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ static const mi_export_t mi_cmds[] = {
{mi_send_sequential_dlg, {"callid", "mode", "body", 0}},
{mi_send_sequential_dlg, {"callid", "method", "body", 0}},
{mi_send_sequential_dlg, {"callid", "method", "body", "mode", 0}},
{mi_send_sequential_dlg, {"callid", "method", "body", "mode", "headers", 0}},
{EMPTY_MI_RECIPE}}
},
{EMPTY_MI_EXPORT}
Expand Down
12 changes: 9 additions & 3 deletions modules/dialog/dlg_req_within.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ static void dlg_sequential_reply(struct cell* t, int type, struct tmcb_params* p
}

static mi_response_t *mi_send_sequential(struct dlg_cell *dlg, int sleg,
str *method, str *body, str *ct, int challenge, struct mi_handler *async_hdl)
str *method, str *body, str *headers, str *ct, int challenge, struct mi_handler *async_hdl)
{
struct dlg_sequential_param *param;
int dleg = other_leg(dlg, sleg);
Expand All @@ -817,7 +817,7 @@ static mi_response_t *mi_send_sequential(struct dlg_cell *dlg, int sleg,
param->method.s = (char *)(param + 1);
memcpy(param->method.s, method->s, method->len);

if (!dlg_get_leg_hdrs(dlg, sleg, dleg, ct, NULL, &extra_headers)) {
if (!dlg_get_leg_hdrs(dlg, sleg, dleg, ct, headers, &extra_headers)) {
LM_ERR("No more pkg for extra headers \n");
shm_free(param);
return init_mi_error(500, MI_SSTR("Internal Error"));
Expand Down Expand Up @@ -953,6 +953,7 @@ mi_response_t *mi_send_sequential_dlg(const mi_params_t *params,
str callid;
str body;
str ct;
str headers;
int leg, challenge, body_mode;

if (get_mi_string_param(params, "callid", &callid.s, &callid.len) < 0)
Expand All @@ -966,6 +967,11 @@ mi_response_t *mi_send_sequential_dlg(const mi_params_t *params,
method.len = 6;
}

if (try_get_mi_string_param(params, "headers", &headers.s, &headers.len) < 0) {
headers.s = "";
headers.len = 0;
}

if ((body_mode = mi_parse_body_mode(params, &ct, &body)) < 0)
return init_mi_error(400, MI_SSTR("Invalid body mode"));

Expand Down Expand Up @@ -998,7 +1004,7 @@ mi_response_t *mi_send_sequential_dlg(const mi_params_t *params,
content = NULL;

return mi_send_sequential(dlg, leg, &method,
(body_mode == 0?NULL:&body), content, challenge, async_hdl);
(body_mode == 0?NULL:&body), &headers, content, challenge, async_hdl);
}

struct dlg_indialog_req_param {
Expand Down
16 changes: 16 additions & 0 deletions modules/dialog/doc/dialog_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3132,6 +3132,10 @@ event_route[E_RTPPROXY_DTMF] {
</para></listitem>
</itemizedlist>
</para></listitem>
<listitem><para>
<emphasis>headers</emphasis> - (optional) can be used to specify some headers for
the initial sequential message.
</para></listitem>
</itemizedlist>
<para>
This functions runs asynchronously and returns the status code and reason
Expand Down Expand Up @@ -3166,6 +3170,18 @@ event_route[E_RTPPROXY_DTMF] {
method=UPDATE
</programlisting>

<para>
MI Command used to send REFER to the callee, and add Refer-To header:
</para>
<programlisting format="linespecific">
opensips-cli -x mi dlg_send_sequential \
callid=usR8FlGOSMfCTAIHebHCOQ.. \
method=REFER \
body=none \
mode=callee \
headers='Refer-To: sip:user@domain:50060'
</programlisting>

</section>
</section>

Expand Down

0 comments on commit 953d138

Please sign in to comment.