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 8aae0b9f08
commit 5bbad0d27c
6 changed files with 134 additions and 7 deletions

View File

@@ -32,9 +32,33 @@
<synopsis>Allow support for RFC3262 provisional ACK tags</synopsis>
<description>
<enumlist>
<enum name="no" />
<enum name="required" />
<enum name="yes" />
<enum name="no">
<para>If set to <literal>no</literal>, do not support transmission of
reliable provisional responses. As UAS, if an incoming request contains 100rel
in the Required header, it is rejected with 420 Bad Extension.</para>
</enum>
<enum name="required">
<para>If set to <literal>required</literal>, require provisional responses to
be sent and received reliably. As UAS, incoming requests without 100rel
in the Supported header are rejected with 421 Extension Required. As UAC,
outgoing requests will have 100rel in the Required header.</para>
</enum>
<enum name="peer_supported">
<para>If set to <literal>peer_supported</literal>, send provisional responses
reliably if the request by the peer contained 100rel in the Supported or
Require header. As UAS, if an incoming request contains 100rel in the Supported
header, send 1xx responses reliably. If the request by the peer does not contain 100rel
in the Supported and Require header, send responses normally. As UAC, outgoing requests
will contain 100rel in the Supported header.</para>
</enum>
<enum name="yes">
<para>If set to <literal>yes</literal>, indicate the support of reliable provisional
responses and PRACK them if required by the peer. As UAS, if the incoming request
contains 100rel in the Supported header but not in the Required header, send 1xx
responses normally. If the incoming request contains 100rel in the Required header,
send 1xx responses reliably. As UAC add 100rel to the Supported header and PRACK 1xx
responses if required.</para>
</enum>
</enumlist>
</description>
</configOption>

View File

@@ -182,9 +182,16 @@ static int prack_handler(const struct aco_option *opt, struct ast_variable *var,
if (ast_true(var->value)) {
endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;
endpoint->rel100 = AST_SIP_100REL_SUPPORTED;
} else if (!strcasecmp(var->value, "peer_supported")) {
endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;
endpoint->rel100 = AST_SIP_100REL_PEER_SUPPORTED;
} else if (!strcasecmp(var->value, "required")) {
endpoint->extensions.flags |= PJSIP_INV_REQUIRE_100REL;
} else if (!ast_false(var->value)){
endpoint->rel100 = AST_SIP_100REL_REQUIRED;
} else if (ast_false(var->value)) {
endpoint->rel100 = AST_SIP_100REL_UNSUPPORTED;
} else {
return -1;
}
@@ -195,10 +202,12 @@ static int prack_to_str(const void *obj, const intptr_t *args, char **buf)
{
const struct ast_sip_endpoint *endpoint = obj;
if (endpoint->extensions.flags & PJSIP_INV_REQUIRE_100REL) {
*buf = "required";
} else if (endpoint->extensions.flags & PJSIP_INV_SUPPORT_100REL) {
if (endpoint->rel100 == AST_SIP_100REL_SUPPORTED) {
*buf = "yes";
} else if (endpoint->rel100 == AST_SIP_100REL_PEER_SUPPORTED) {
*buf = "peer_supported";
} else if (endpoint->rel100 == AST_SIP_100REL_REQUIRED) {
*buf = "required";
} else {
*buf = "no";
}