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

Added support for updated RFC7866 content-type sub type with XML extension #4270

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 21 additions & 11 deletions pjsip/src/pjsip-ua/sip_siprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
status = pjsip_siprec_get_metadata(rdata->tp_info.pool,
rdata->msg_info.msg->body,
metadata);

if(status != PJ_SUCCESS) {
code = PJSIP_SC_BAD_REQUEST;
warn_text = "SIPREC INVITE must have a 'rs-metadata' Content-Type";
warn_text = "SIPREC INVITE must have a content-type of 'rs-metadata' or with XML extension 'rs-metadata+xml'";
goto on_return;
}

Expand Down Expand Up @@ -265,21 +265,31 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
* Find siprec metadata from the message body
*/
PJ_DEF(pj_status_t) pjsip_siprec_get_metadata(pj_pool_t *pool,
pjsip_msg_body *body,
pj_str_t* metadata)
pjsip_msg_body *body,
pj_str_t* metadata)
{
pjsip_media_type app_metadata;
pjsip_multipart_part *metadata_part;

PJ_UNUSED_ARG(pool);
pjsip_media_type_init2(&app_metadata, "application", "rs-metadata");
metadata_part = pjsip_multipart_find_part(body, &app_metadata, NULL);
pjsip_media_type application_metadata;
pjsip_multipart_part *metadata_part = NULL;

/*
* Updated to support RFC base content type extension
* https://datatracker.ietf.org/doc/html/draft-sipcore-siprec-fix-mediatype-00
*/
/* Try rs-metadata first */
pjsip_media_type_init2(&application_metadata, "application", "rs-metadata");
metadata_part = pjsip_multipart_find_part(body, &application_metadata, NULL);

/* Fallback to XML extension rs-metadata+xml if needed */
if (!metadata_part) {
pjsip_media_type_init2(&application_metadata, "application", "rs-metadata+xml");
metadata_part = pjsip_multipart_find_part(body, &application_metadata, NULL);
}

if(!metadata_part)
return PJ_ENOTFOUND;

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

return PJ_SUCCESS;
}