Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include PJSIP module data in cloning pjsip_rx_data #3797

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion pjsip/include/pjsip/sip_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,33 @@ struct pjsip_rx_data

};


/**
* This enumerator describes the options for cloning pjsip_rx_data.
*/
typedef enum pjsip_rx_data_clone_flag
{
/**
* The clone will copy transport pointer in \a tp_info, duplicates
* the \a pkt_info, perform deep clone of the \a msg_info parts of
* the rdata, and fills the \a endpt_info (i.e. the \a mod_data)
* with zeros.
*/
PJSIP_RX_DATA_CLONE_DEFAULT = 0,

/**
* The clone behavior will be the same as PJSIP_RX_DATA_CLONE_DEFAULT,
* except this will also copy the \a endpt_info (i.e. the \a mod_data).
*
* The mod_data is used by PJSIP module to store its data, for example
* the transaction module uses it to link pjsip_rx_data to transaction
* instance (see pjsip_rdata_get_tsx()).
*/
PJSIP_RX_DATA_CLONE_ENDPT_INFO = 1

} pjsip_rx_data_clone_flag;


/**
* Get printable information about the message in the rdata.
*
Expand All @@ -484,7 +511,7 @@ PJ_DECL(char*) pjsip_rx_data_get_info(pjsip_rx_data *rdata);
* fills the \a endpt_info (i.e. the \a mod_data) with zeros.
*
* @param src The source to be cloned.
* @param flags Optional flags. Must be zero for now.
* @param flags The clone flags, see #pjsip_rx_data_clone_flag.
* @param p_rdata Pointer to receive the cloned rdata.
*
* @return PJ_SUCCESS on success or the appropriate error.
Expand Down
8 changes: 7 additions & 1 deletion pjsip/src/pjsip/sip_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,8 @@ PJ_DEF(pj_status_t) pjsip_rx_data_clone( const pjsip_rx_data *src,
pjsip_rx_data *dst;
pjsip_hdr *hdr;

PJ_ASSERT_RETURN(src && flags==0 && p_rdata, PJ_EINVAL);
PJ_ASSERT_RETURN(src && p_rdata, PJ_EINVAL);
PJ_ASSERT_RETURN(flags <= PJSIP_RX_DATA_CLONE_ENDPT_INFO, PJ_EINVAL);

pool = pj_pool_create(src->tp_info.pool->factory,
"rtd%p",
Expand Down Expand Up @@ -839,6 +840,11 @@ PJ_DEF(pj_status_t) pjsip_rx_data_clone( const pjsip_rx_data *src,
#undef GET_MSG_HDR
#undef GET_MSG_HDR2

/* Copy endpt_info */
if (flags == PJSIP_RX_DATA_CLONE_ENDPT_INFO) {
pj_memcpy(&dst->endpt_info, &src->endpt_info, sizeof(src->endpt_info));
}

*p_rdata = dst;

/* Finally add transport ref */
Expand Down
Loading