Skip to content

Commit

Permalink
call_center: fix usage of parameter passed to cc_handle_call
Browse files Browse the repository at this point in the history
(cherry picked from commit d6bcd2d)
  • Loading branch information
razvancrainea committed Oct 31, 2023
1 parent 5115c4d commit 54e4922
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/b2b_logic/b2b_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ typedef struct b2bl_init_params {
str e2_to;
str e1_from_dname;
str e2_from_dname;
str ctx_key;
str ctx_val;
} b2bl_init_params_t;


Expand Down
2 changes: 2 additions & 0 deletions modules/b2b_logic/logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2771,6 +2771,8 @@ str* b2bl_init_extern(struct b2b_params *init_params,
/* set the context values given in the b2b_trigger_scenario MI cmd */
tuple->vals = local_ctx_vals;
local_ctx_vals = NULL;
if (scen_params->ctx_key.len)
store_ctx_value(&tuple->vals, &scen_params->ctx_key, &scen_params->ctx_val);

memset(&e1, 0, sizeof e1);
memset(&e2, 0, sizeof e1);
Expand Down
11 changes: 11 additions & 0 deletions modules/call_center/call_center.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static str rt_db_url = {NULL, 0};;
static struct cc_data *data=NULL;
static str b2b_scenario = str_init("call center");
static str b2b_scenario_agent = str_init("call center agent");
static str b2b_logic_ctx_param = str_init("call_center");

/* b2b logic API */
b2bl_api_t b2b_api;
Expand Down Expand Up @@ -168,6 +169,7 @@ static const param_export_t mod_params[]={
{ "ccf_m_dissuading_column",
STR_PARAM, &ccf_m_dissuading_column.s },
{ "ccf_m_flow_id_column", STR_PARAM, &ccf_m_flow_id_column.s },
{ "b2b_logic_ctx_param", STR_PARAM, &b2b_logic_ctx_param.s },
{ 0,0,0 }
};

Expand Down Expand Up @@ -374,6 +376,7 @@ static int mod_init(void)
ccf_m_queue_column.len = strlen(ccf_m_queue_column.s);
ccf_m_dissuading_column.len = strlen(ccf_m_dissuading_column.s);
ccf_m_flow_id_column.len = strlen(ccf_m_flow_id_column.s);
b2b_logic_ctx_param.len = strlen(b2b_logic_ctx_param.s);

if (queue_pos_param.s)
queue_pos_param.len = strlen(queue_pos_param.s);
Expand Down Expand Up @@ -988,6 +991,10 @@ int set_call_leg( struct sip_msg *msg, struct cc_call *call, str *new_leg)
b2b_params.e1_from_dname = call->caller_dn;
b2b_params.e2_type = B2B_CLIENT;
b2b_params.e2_to = *new_leg;
if (call->script_param.len) {
b2b_params.ctx_key = b2b_logic_ctx_param;
b2b_params.ctx_val = call->script_param;
}

id = b2b_api.init(NULL, &b2b_scenario_agent, &b2b_params, b2bl_callback_agent,
(void*)call, B2B_DESTROY_CB|B2B_REJECT_CB|B2B_BYE_CB, NULL);
Expand All @@ -1014,6 +1021,10 @@ int set_call_leg( struct sip_msg *msg, struct cc_call *call, str *new_leg)
b2b_params.e1_type = B2B_SERVER;
b2b_params.e2_type = B2B_CLIENT;
b2b_params.e2_to = *new_leg;
if (call->script_param.len) {
b2b_params.ctx_key = b2b_logic_ctx_param;
b2b_params.ctx_val = call->script_param;
}

id = b2b_api.init(msg, &b2b_scenario, &b2b_params, b2bl_callback_customer,
(void*)call, B2B_DESTROY_CB|B2B_REJECT_CB|B2B_BYE_CB, NULL /* custom_hdrs */ );
Expand Down
42 changes: 42 additions & 0 deletions modules/call_center/doc/call_center_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,44 @@ modparam("call_center", "ccf_m_dissuading_column", "audio_dissuading")
...
modparam("call_center", "ccf_m_flow_id_column", "audio_flow_id")
...
</programlisting>
</example>
</section>

<section id="param_b2b_logic_ctx_param" xreflabel="b2b_logic_ctx_param">
<title><varname>b2b_logic_ctx_param</varname> (string)</title>
<para>
The name of the <emphasis>$b2b_logic.ctx</emphasis> variable that can be
used to retrieve the value of the parameter passed to
the <xref linkend="func_cc_handle_call"/> function.
</para>
<para>
This parameter will be copied throughout all the B2B scenarios started
by the call_center module. NOTE that you can change the value of the current
scenario by writing into it, but the change will not be reflected in a
different scenario.
</para>
<para>
<emphasis>Default value is <quote>call_center</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>b2b_logic_ctx_param</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("call_center", "b2b_logic_ctx_param", "b2b_callid")
...
route[handle_call_center] {
...
cc_handle_call("flow", $ci);
...
}
...
route[b2b_handle_request] {
...
xlog("Initial Callid is $b2b_logic.ctx(b2b_callid)\n");
...
}
</programlisting>
</example>
</section>
Expand Down Expand Up @@ -898,6 +936,10 @@ modparam("call_center", "ccf_m_flow_id_column", "audio_flow_id")
intended for custom integration of the call center module and
it is 100% up to the script writer about the value and purpose
of this parameter, OpenSIPS will not touch or interpret it.
You can retrieve the value of this parameter using the
<emphasis>$b2b_logic.ctx</emphasis> variable with the name
defined in the <xref linkend="param_b2b_logic_ctx_param"/>
parameter.
</para></listitem>
</itemizedlist>
<para>
Expand Down

0 comments on commit 54e4922

Please sign in to comment.