Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
sorooshm78 committed Dec 12, 2024
1 parent 098d22a commit 3853872
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
9 changes: 6 additions & 3 deletions pjsip/include/pjsip-ua/sip_siprec.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ PJ_DECL(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
* @param pool Pool to allocate memory.
* @param body The message body.
* @param metadata The siprec metadata
*
* @return Return PJ_SUCCESS if metadata exists.
*/
PJ_DECL(void) pjsip_siprec_find_metadata(pj_pool_t *pool,
pjsip_msg_body *body,
pj_str_t* metadata);

PJ_DECL(pj_status_t) pjsip_siprec_get_metadata(pj_pool_t *pool,
pjsip_msg_body *body,
pj_str_t* metadata);


PJ_END_DECL
Expand Down
17 changes: 9 additions & 8 deletions pjsip/src/pjsip-ua/sip_siprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
goto on_return;
}

pjsip_siprec_find_metadata(rdata->tp_info.pool,
rdata->msg_info.msg->body,
metadata);
status = pjsip_siprec_get_metadata(rdata->tp_info.pool,
rdata->msg_info.msg->body,
metadata);

if(metadata->ptr == NULL || metadata->slen == 0) {
if(status != PJ_SUCCESS) {
code = PJSIP_SC_BAD_REQUEST;
warn_text = "SIPREC INVITE must have a 'rs-metadata+xml' Content-Type";
goto on_return;
Expand Down Expand Up @@ -225,7 +225,7 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
/**
* Find siprec metadata from the message body
*/
PJ_DEF(void) pjsip_siprec_find_metadata(pj_pool_t *pool,
PJ_DEF(pj_status_t) pjsip_siprec_get_metadata(pj_pool_t *pool,
pjsip_msg_body *body,
pj_str_t* metadata)
{
Expand All @@ -236,10 +236,11 @@ PJ_DEF(void) pjsip_siprec_find_metadata(pj_pool_t *pool,
pjsip_multipart_part *metadata_part;
metadata_part = pjsip_multipart_find_part(body, &application_metadata, NULL);

if(!metadata_part) {
return;
}
if(!metadata_part)
return PJ_ENOTFOUND;

metadata->ptr = (char*)metadata_part->body->data;
metadata->slen = metadata_part->body->len;

return PJ_SUCCESS;
}

0 comments on commit 3853872

Please sign in to comment.