Skip to content

Commit

Permalink
msrp_ua: fix the RURI param of E_MSRP_SESSION_NEW
Browse files Browse the repository at this point in the history
(cherry picked from commit a7bf9e9)
  • Loading branch information
rvlad-patrascu committed Oct 11, 2022
1 parent 89f5602 commit 998d1e7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
34 changes: 27 additions & 7 deletions modules/msrp_ua/msrp_ua.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ static void free_msrpua_session(void *val)
if (sess->dlginfo)
shm_free(sess->dlginfo);

if (sess->ruri.s)
shm_free(sess->ruri.s);

shm_free(sess);
}

Expand Down Expand Up @@ -935,7 +938,7 @@ static int msrpua_update_session(struct msrpua_session *sess,
return -1;
}

static int raise_sess_new_event(struct sip_msg *msg, str *sess_id,
static int raise_sess_new_event(struct sip_msg *msg, str *sess_id, str *ruri,
str *accept_types)
{
if (parse_from_header(msg) < 0) {
Expand All @@ -955,7 +958,7 @@ static int raise_sess_new_event(struct sip_msg *msg, str *sess_id,
LM_ERR("cannot set event parameter\n");
return -1;
}
if (evi_param_set_str(evi_sess_ruri_p, GET_RURI(msg)) < 0) {
if (evi_param_set_str(evi_sess_ruri_p, ruri) < 0) {
LM_ERR("cannot set event parameter\n");
return -1;
}
Expand Down Expand Up @@ -1077,12 +1080,17 @@ static int b2b_notify_request(int etype, struct sip_msg *msg, str *key,
hash_unlock(msrpua_sessions, hentry);

if (!cb_params.event) {
if (raise_sess_new_event(msg, &sess_id, &accept_types) < 0)
if (raise_sess_new_event(msg, &sess_id, &sess->ruri,
&accept_types) < 0)
LM_ERR("Failed to raise session new event on ACK\n");
} else {
hdl.notify_cb(&cb_params, hdl.param);
}

/* we only needed the ruri for the E_MSRP_SESSION_NEW event params */
shm_free(sess->ruri.s);
sess->ruri.s = NULL;

pkg_free(sess_id.s);
pkg_free(accept_types.s);
} else if (!(flags & B2B_NOTIFY_FL_ACK_NEG)) {
Expand Down Expand Up @@ -1309,12 +1317,17 @@ static int b2b_notify_reply(int etype, struct sip_msg *msg, str *key,
}

if (!cb_params.event) {
if (raise_sess_new_event(msg, &sess_id, &peer_accept_types) < 0)
if (raise_sess_new_event(msg, &sess_id, &sess->ruri,
&peer_accept_types) < 0)
LM_ERR("Failed to raise session new event on ACK\n");
} else {
hdl.notify_cb(&cb_params, hdl.param);
}

/* we only needed the ruri for the E_MSRP_SESSION_NEW event params */
shm_free(sess->ruri.s);
sess->ruri.s = NULL;

pkg_free(sess_id.s);
}
}
Expand Down Expand Up @@ -1387,7 +1400,7 @@ static inline void msrpua_gen_id(char *dest, str *src1, str *src2)

/* if successful, returns with the session lock aquired */
static struct msrpua_session *new_msrpua_session(int b2b_type, str *id_src1,
str *id_src2, str *accept_types, struct msrp_ua_handler *hdl)
str *id_src2, str *ruri, str *accept_types, struct msrp_ua_handler *hdl)
{
unsigned int hentry;
void **val;
Expand All @@ -1413,6 +1426,9 @@ static struct msrpua_session *new_msrpua_session(int b2b_type, str *id_src1,
sess->lifetime = MSRPUA_SESS_SETUP_TOUT + get_ticks();
sess->dlg_state = MSRPUA_DLG_NEW;

if (shm_str_dup(&sess->ruri, ruri) < 0)
goto error;

hentry = hash_entry(msrpua_sessions, sess->session_id);
hash_lock(msrpua_sessions, hentry);

Expand All @@ -1437,6 +1453,8 @@ static struct msrpua_session *new_msrpua_session(int b2b_type, str *id_src1,

return sess;
error:
if (sess->ruri.s)
shm_free(sess->ruri.s);
shm_free(sess);
return NULL;
}
Expand Down Expand Up @@ -1647,7 +1665,8 @@ static int msrpua_init_uas(struct sip_msg *msg, str *accept_types,
return -1;
}

sess = new_msrpua_session(B2B_SERVER, &callid, NULL, accept_types, hdl);
sess = new_msrpua_session(B2B_SERVER, &callid, NULL, GET_RURI(msg),
accept_types, hdl);
if (!sess) {
LM_ERR("Failed to create new MSRP UA session\n");
return -1;
Expand Down Expand Up @@ -1830,7 +1849,8 @@ static int msrpua_init_uac(str *accept_types, str *from_uri, str *to_uri,
unsigned int hentry;
struct msrpua_session *sess;

sess = new_msrpua_session(B2B_CLIENT, from_uri, to_uri, accept_types, hdl);
sess = new_msrpua_session(B2B_CLIENT, from_uri, to_uri, ruri, accept_types,
hdl);
if (!sess) {
LM_ERR("Failed to create new MSRP UA session\n");
return -1;
Expand Down
1 change: 1 addition & 0 deletions modules/msrp_ua/msrp_ua.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct msrpua_session {
str b2b_key;
enum b2b_entity_type b2b_type;
msrpua_dlg_state_t dlg_state;
str ruri;
str accept_types;
str peer_accept_types;
str use_path;
Expand Down

0 comments on commit 998d1e7

Please sign in to comment.