Skip to content

Commit

Permalink
Merge pull request #1914 from vasilevalex/usrloc_event_ua
Browse files Browse the repository at this point in the history
usrloc: Add "user_agent" parameter to E_UL_CONTACT events
  • Loading branch information
razvancrainea committed Dec 18, 2019
2 parents a413f58 + 369a2ed commit 52f675b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/usrloc/doc/usrloc_admin.xml
Expand Up @@ -1752,6 +1752,12 @@ modparam("usrloc", "mi_dump_kv_store", 1)
<emphasis>qval</emphasis> - The Q value (priority) of the
contact (as integer value from 0 to 10).
</para></listitem>
<listitem><para>
<emphasis>user_agent</emphasis> - The User-Agent header
value.
</para>
<para><emphasis>NOTICE: </emphasis>Can contain spaces.
</para></listitem>
<listitem><para>
<emphasis>socket</emphasis> - The SIP socket/listener
(as string) used by OpenSIPS to receive the contact
Expand Down
15 changes: 15 additions & 0 deletions modules/usrloc/udomain.c
Expand Up @@ -151,6 +151,7 @@ static str ei_c_uri_name = str_init("uri");
static str ei_c_recv_name = str_init("received");
static str ei_c_path_name = str_init("path");
static str ei_c_qval_name = str_init("qval");
static str ei_c_user_agent_name = str_init("user_agent");
static str ei_c_socket_name = str_init("socket");
static str ei_c_bflags_name = str_init("bflags");
static str ei_c_expires_name = str_init("expires");
Expand All @@ -169,6 +170,7 @@ static evi_param_p ul_c_uri_param;
static evi_param_p ul_c_recv_param;
static evi_param_p ul_c_path_param;
static evi_param_p ul_c_qval_param;
static evi_param_p ul_c_user_agent_param;
static evi_param_p ul_c_socket_param;
static evi_param_p ul_c_bflags_param;
static evi_param_p ul_c_expires_param;
Expand Down Expand Up @@ -272,6 +274,13 @@ int ul_event_init(void)
return -1;
}

ul_c_user_agent_param = evi_param_create(ul_contact_event_params,
&ei_c_user_agent_name);
if (!ul_c_user_agent_param) {
LM_ERR("cannot create user_agent parameter\n");
return -1;
}

ul_c_socket_param = evi_param_create(ul_contact_event_params,
&ei_c_socket_name);
if (!ul_c_socket_param) {
Expand Down Expand Up @@ -383,6 +392,12 @@ void ul_raise_contact_event(event_id_t _e, struct ucontact *_c)
return;
}

/* the User Agent */
if (evi_param_set_str(ul_c_user_agent_param, &_c->user_agent) < 0) {
LM_ERR("cannot set user_agent parameter\n");
return;
}

/* the socket */
if (evi_param_set_str(ul_c_socket_param,
(_c->sock ? &_c->sock->sock_str : &str_empty)) < 0) {
Expand Down

0 comments on commit 52f675b

Please sign in to comment.