Merge "res_pjsip_messaging: Allow application/* for in-dialog MESSAGEs" into 13

13.23
Jenkins2 7 years ago committed by Gerrit Code Review
commit a5754e7904

@ -4930,8 +4930,8 @@ int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body); ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
res = ast_channel_tech(chan)->send_text(chan, body); res = ast_channel_tech(chan)->send_text(chan, body);
} else { } else {
ast_debug(1, "Channel technology does not support sending text on channel '%s'\n", ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
ast_channel_name(chan)); S_OR(content_type, "text/plain"), ast_channel_name(chan));
res = -1; res = -1;
} }
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);

@ -80,22 +80,25 @@ static enum pjsip_status_code check_content_type(const pjsip_rx_data *rdata)
* \internal * \internal
* \brief Checks to make sure the request has the correct content type. * \brief Checks to make sure the request has the correct content type.
* *
* \details This module supports the following media types: "text/\*". * \details This module supports the following media types: "text/\*", "application/\*".
* Return unsupported otherwise. * Return unsupported otherwise.
* *
* \param rdata The SIP request * \param rdata The SIP request
*/ */
static enum pjsip_status_code check_content_type_any_text(const pjsip_rx_data *rdata) static enum pjsip_status_code check_content_type_in_dialog(const pjsip_rx_data *rdata)
{ {
int res = PJSIP_SC_UNSUPPORTED_MEDIA_TYPE; int res = PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
pj_str_t text = { "text", 4}; static const pj_str_t text = { "text", 4};
static const pj_str_t application = { "application", 11};
/* We'll accept any text/ content type */ /* We'll accept any text/ or application/ content type */
if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len
&& pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0) { && (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
|| pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0)) {
res = PJSIP_SC_OK; res = PJSIP_SC_OK;
} else if (rdata->msg_info.ctype } else if (rdata->msg_info.ctype
&& pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0) { && (pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0
|| pj_stricmp(&rdata->msg_info.ctype->media.type, &application) == 0)) {
res = PJSIP_SC_OK; res = PJSIP_SC_OK;
} }
@ -800,7 +803,7 @@ static int incoming_in_dialog_request(struct ast_sip_session *session, struct pj
return 0; return 0;
} }
code = check_content_type_any_text(rdata); code = check_content_type_in_dialog(rdata);
if (code != PJSIP_SC_OK) { if (code != PJSIP_SC_OK) {
send_response(rdata, code, dlg, tsx); send_response(rdata, code, dlg, tsx);
return 0; return 0;
@ -849,7 +852,7 @@ static int incoming_in_dialog_request(struct ast_sip_session *session, struct pj
send_response(rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, dlg, tsx); send_response(rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, dlg, tsx);
return 0; return 0;
} }
ast_copy_string(attrs[pos].value, rdata->msg_info.msg->body->data, rdata->msg_info.msg->body->len); ast_copy_string(attrs[pos].value, rdata->msg_info.msg->body->data, rdata->msg_info.msg->body->len + 1);
pos++; pos++;
msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG, attrs, pos); msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG, attrs, pos);

Loading…
Cancel
Save