res_pjsip: Add 100rel option "peer_supported".

This patch adds a new option to the 100rel parameter for pjsip
endpoints called "peer_supported". When an endpoint with this option
receives an incoming request and the request indicated support for the
100rel extension, then Asterisk will send 1xx responses reliably. If
the request did not indicate 100rel support, Asterisk sends 1xx
responses normally.

ASTERISK-30158

Change-Id: Id6d95ffa8f00dab118e0b386146e99f254f287ad
This commit is contained in:
Maximilian Fridrich
2022-07-26 15:40:26 +02:00
committed by Michael Bradeen
parent 2043234cf4
commit 492c93861c
6 changed files with 134 additions and 7 deletions

View File

@@ -3789,8 +3789,23 @@ static pjsip_inv_session *pre_session_setup(pjsip_rx_data *rdata, const struct a
pjsip_dialog *dlg;
pjsip_inv_session *inv_session;
unsigned int options = endpoint->extensions.flags;
const pj_str_t STR_100REL = { "100rel", 6};
unsigned int i;
pj_status_t dlg_status = PJ_EUNKNOWN;
/*
* If 100rel is set to "peer_supported" on the endpoint and the peer indicated support for 100rel
* in the Supported header, send 1xx responses reliably by adding PJSIP_INV_REQUIRE_100REL to pjsip_inv_options flags.
*/
if (endpoint->rel100 == AST_SIP_100REL_PEER_SUPPORTED && rdata->msg_info.supported != NULL) {
for (i = 0; i < rdata->msg_info.supported->count; ++i) {
if (pj_stricmp(&rdata->msg_info.supported->values[i], &STR_100REL) == 0) {
options |= PJSIP_INV_REQUIRE_100REL;
break;
}
}
}
if (pjsip_inv_verify_request(rdata, &options, NULL, NULL, ast_sip_get_pjsip_endpoint(), &tdata) != PJ_SUCCESS) {
if (tdata) {
if (pjsip_endpt_send_response2(ast_sip_get_pjsip_endpoint(), rdata, tdata, NULL, NULL) != PJ_SUCCESS) {