Skip to content

Commit 3f0033c

Browse files
committed
b2b_entities: add support for using extra_params for ua_server_init
1 parent 36b916a commit 3f0033c

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

modules/b2b_entities/b2b_entities.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static const cmd_export_t cmds[] = {
101101
{CMD_PARAM_VAR|CMD_PARAM_OPT, 0, 0},
102102
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
103103
fixup_ua_flags, fixup_free_ua_flags},
104+
{CMD_PARAM_STR|CMD_PARAM_OPT, 0, 0},
104105
{0,0,0}},
105106
REQUEST_ROUTE},
106107
{"ua_session_update", (cmd_function)b2b_ua_update, {

modules/b2b_entities/dlg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ int b2b_prescript_f(struct sip_msg *msg, void *uparam)
13611361
}
13621362

13631363
if (ua_ev_type != -1 && raise_ua_sess_event(&b2b_key, etype, ua_ev_type,
1364-
ua_flags, msg) < 0) {
1364+
ua_flags, msg, NULL) < 0) {
13651365
LM_ERR("Failed to raise E_UA_SESSION event\n");
13661366
return SCB_DROP_MSG;
13671367
}
@@ -3673,7 +3673,7 @@ void b2b_tm_cback(struct cell *t, b2b_table htable, struct tmcb_params *ps)
36733673
else
36743674
ua_ev_type = UA_SESS_EV_REJECTED;
36753675

3676-
if (raise_ua_sess_event(b2b_key, etype, ua_ev_type, ua_flags, msg) < 0) {
3676+
if (raise_ua_sess_event(b2b_key, etype, ua_ev_type, ua_flags, msg, NULL) < 0) {
36773677
LM_ERR("Failed to raise E_UA_SESSION event\n");
36783678
goto error1;
36793679
}

modules/b2b_entities/doc/b2b_entities_admin.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ modparam("b2b_entities", "ua_default_timeout", 7200)
375375
<title>Exported Functions</title>
376376
<section id="func_ua_session_server_init" xreflabel="ua_session_server_init()">
377377
<title>
378-
<function moreinfo="none">ua_session_server_init([key], [flags])</function>
378+
<function moreinfo="none">ua_session_server_init([key], [flags], [extra_params])</function>
379379
</title>
380380
<para>
381381
This function initializes a new UA session by processing an initial INVITE.
@@ -429,6 +429,11 @@ modparam("b2b_entities", "ua_default_timeout", 7200)
429429
</para></listitem>
430430
</itemizedlist>
431431
</para></listitem>
432+
<listitem><para>
433+
<emphasis>extra_params (string, optional)</emphasis> - An arbitrary
434+
value to be passed to the <emphasis>extra_params</emphasis> parameter
435+
in the <xref linkend="event_E_UA_SESSION"/> event.
436+
</para></listitem>
432437
</itemizedlist>
433438
<para>
434439
This function can be used from REQUEST_ROUTE.
@@ -875,6 +880,12 @@ opensips-cli -x mi ua_session_terminate key=B2B.436.1925389.1649338095
875880
<emphasis>headers</emphasis> - full list of all SIP headers in the
876881
message.
877882
</para></listitem>
883+
<listitem><para>
884+
<emphasis>extra_params</emphasis> - an arbitrary value. Currently only
885+
the <xref linkend="func_ua_session_server_init"/> function passes this
886+
if the <emphasis>extra_params</emphasis> argument is used, and it only
887+
appears in the <emphasis>NEW</emphasis> event_type.
888+
</para></listitem>
878889
</itemizedlist>
879890
</section>
880891

modules/b2b_entities/ua_api.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static str evi_ua_sess_name = str_init("E_UA_SESSION");
5858
static evi_params_p evi_ua_sess_params;
5959
static evi_param_p evi_key_param, evi_ev_type_param, evi_ent_type_param,
6060
evi_status_param, evi_reason_param, evi_method_param, evi_body_param,
61-
evi_headers_param;
61+
evi_headers_param, evi_extra_param;
6262

6363
static str evi_key_pname = str_init("key");
6464
static str evi_ent_type_pname = str_init("entity_type");
@@ -68,6 +68,7 @@ static str evi_reason_pname = str_init("reason");
6868
static str evi_method_pname = str_init("method");
6969
static str evi_body_pname = str_init("body");
7070
static str evi_headers_pname = str_init("headers");
71+
static str evi_extra_pname = str_init("extra_params");
7172

7273
int ua_evi_init(void)
7374
{
@@ -116,6 +117,10 @@ int ua_evi_init(void)
116117
&evi_headers_pname);
117118
if (evi_headers_param == NULL)
118119
goto error;
120+
evi_extra_param = evi_param_create(evi_ua_sess_params,
121+
&evi_extra_pname);
122+
if (evi_extra_param == NULL)
123+
goto error;
119124

120125
return 0;
121126
error:
@@ -164,7 +169,7 @@ static str event_type_str[] = {
164169
static str entity_type_str[] = {str_init("UAS"), str_init("UAC")};
165170

166171
int raise_ua_sess_event(str *key, enum b2b_entity_type ent_type,
167-
enum ua_sess_event_type ev_type, unsigned int flags, struct sip_msg *msg)
172+
enum ua_sess_event_type ev_type, unsigned int flags, struct sip_msg *msg, str *extra)
168173
{
169174
str body = {0,0};
170175
str hdrs = {0,0};
@@ -232,6 +237,11 @@ int raise_ua_sess_event(str *key, enum b2b_entity_type ent_type,
232237
goto error;
233238
}
234239

240+
if (evi_param_set_str(evi_extra_param, (extra?extra:&empty)) < 0) {
241+
LM_ERR("cannot set event extra parameter\n");
242+
goto error;
243+
}
244+
235245
if (evi_raise_event(evi_ua_sess_id, evi_ua_sess_params) < 0) {
236246
LM_ERR("cannot raise event\n");
237247
goto error;
@@ -774,7 +784,7 @@ int b2b_ua_reply(struct sip_msg *msg, str *key, str *method, int *code,
774784
}
775785

776786
int b2b_ua_server_init(struct sip_msg *msg, pv_spec_t *key_spec,
777-
struct ua_sess_init_params *init_params)
787+
struct ua_sess_init_params *init_params, str *extra)
778788
{
779789
pv_value_t key_pval;
780790
str *key_ret = NULL;
@@ -810,7 +820,7 @@ int b2b_ua_server_init(struct sip_msg *msg, pv_spec_t *key_spec,
810820

811821
if (!(init_params->flags&UA_FL_SUPPRESS_NEW) &&
812822
raise_ua_sess_event(key_ret, B2B_SERVER, UA_SESS_EV_NEW,
813-
init_params->flags, msg) < 0) {
823+
init_params->flags, msg, NULL) < 0) {
814824
LM_ERR("Failed to raise E_UA_SESSION event\n");
815825
goto error;
816826
}

modules/b2b_entities/ua_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int fixup_ua_flags(void** param);
9292
int fixup_free_ua_flags(void** param);
9393

9494
int b2b_ua_server_init(struct sip_msg *msg, pv_spec_t *key_spec,
95-
struct ua_sess_init_params *init_params);
95+
struct ua_sess_init_params *init_params, str *extra);
9696
int b2b_ua_update(struct sip_msg *msg, str *key, str *method, str *body,
9797
str *extra_headers, str *content_type);
9898
int b2b_ua_reply(struct sip_msg *msg, str *key, str *method, int *code,
@@ -112,6 +112,6 @@ mi_response_t *b2b_ua_session_list(const mi_params_t *params,
112112

113113
int ua_evi_init(void);
114114
int raise_ua_sess_event(str *key, enum b2b_entity_type ent_type,
115-
enum ua_sess_event_type ev_type, unsigned int flags, struct sip_msg *msg);
115+
enum ua_sess_event_type ev_type, unsigned int flags, struct sip_msg *msg, str *extra);
116116

117-
#endif
117+
#endif

0 commit comments

Comments
 (0)