chan_pjsip: add allow_sending_180_after_183 option

added new global config option "allow_sending_180_after_183"
that if enabled will preserve 180 after a 183

ASTERISK-29842

Change-Id: I8a53f8c35595b6d16d8e86e241b5f110d92f3d18
This commit is contained in:
Mark Petersen 2022-02-21 14:23:21 +01:00 committed by Friendly Automation
parent d33050f172
commit bd5cc4c81e
7 changed files with 94 additions and 1 deletions

View File

@ -1614,8 +1614,12 @@ static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const voi
if (channel->session->endpoint->inband_progress ||
(channel->session->inv_session && channel->session->inv_session->neg &&
pjmedia_sdp_neg_get_state(channel->session->inv_session->neg) == PJMEDIA_SDP_NEG_STATE_DONE)) {
response_code = 183;
res = -1;
if (ast_sip_get_allow_sending_180_after_183()) {
response_code = 180;
} else {
response_code = 183;
}
} else {
response_code = 180;
}

View File

@ -1258,6 +1258,12 @@
; creating an implicit subscription (see RFC 4488).
; (default: "yes")
;allow_sending_180_after_183=yes ; Allow Asterisk to send 180 Ringing to an endpoint
; after 183 Session Progress has been send.
; If disabled Asterisk will instead send only a
; 183 Session Progress to the endpoint.
; (default: "no")
; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl
;==========================ACL SECTION OPTIONS=========================
;[acl]

View File

@ -0,0 +1,36 @@
"""allow_sending_180_after_183
Revision ID: 0bee61aa9425
Revises: 8f72185e437f
Create Date: 2022-04-07 13:51:33.400664
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ENUM
# revision identifiers, used by Alembic.
revision = '0bee61aa9425'
down_revision = '8f72185e437f'
AST_BOOL_NAME = 'ast_bool_values'
# We'll just ignore the n/y and f/t abbreviations as Asterisk does not write
# those aliases.
AST_BOOL_VALUES = [ '0', '1',
'off', 'on',
'false', 'true',
'no', 'yes' ]
def upgrade():
############################# Enums ##############################
# ast_bool_values has already been created, so use postgres enum object
# type to get around "already created" issue - works okay with mysql
ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
op.add_column('ps_globals', sa.Column('allow_sending_180_after_183', ast_bool_values))
def downgrade():
if op.get_context().bind.dialect.name == 'mssql':
op.drop_constraint('ck_ps_globals_allow_sending_180_after_183_ast_bool_values', 'ps_globals')
op.drop_column('ps_globals', 'allow_sending_180_after_183')

View File

@ -0,0 +1,8 @@
Subject: chan_pjsip
added global config option "allow_sending_180_after_183"
Allow Asterisk to send 180 Ringing to an endpoint
after 183 Session Progress has been send.
If disabled Asterisk will instead send only a
183 Session Progress to the endpoint.

View File

@ -2989,6 +2989,13 @@ int ast_sip_get_mwi_tps_queue_low(void);
*/
unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void);
/*!
* \brief Retrieve the global setting 'allow_sending_180_after_183'.
*
* \retval non zero if disable.
*/
unsigned int ast_sip_get_allow_sending_180_after_183(void);
/*!
* \brief Retrieve the global setting 'use_callerid_contact'.
* \since 13.24.0

View File

@ -48,6 +48,7 @@
#define DEFAULT_MWI_TPS_QUEUE_HIGH AST_TASKPROCESSOR_HIGH_WATER_LEVEL
#define DEFAULT_MWI_TPS_QUEUE_LOW -1
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED 0
#define DEFAULT_ALLOW_SENDING_180_AFTER_183 0
#define DEFAULT_IGNORE_URI_USER_OPTIONS 0
#define DEFAULT_USE_CALLERID_CONTACT 0
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION 0
@ -92,6 +93,8 @@ struct global_config {
unsigned int contact_expiration_check_interval;
/*! Nonzero to disable multi domain support */
unsigned int disable_multi_domain;
/*! Nonzero to disable changing 180/SDP to 183/SDP */
unsigned int allow_sending_180_after_183;
/*! The maximum number of unidentified requests per source IP address before a security event is logged */
unsigned int unidentified_request_count;
/*! The period during which unidentified requests are accumulated */
@ -444,6 +447,21 @@ unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void)
return disable_initial_unsolicited;
}
unsigned int ast_sip_get_allow_sending_180_after_183(void)
{
unsigned int allow_sending_180_after_183;
struct global_config *cfg;
cfg = get_global_cfg();
if (!cfg) {
return DEFAULT_ALLOW_SENDING_180_AFTER_183;
}
allow_sending_180_after_183 = cfg->allow_sending_180_after_183;
ao2_ref(cfg, -1);
return allow_sending_180_after_183;
}
unsigned int ast_sip_get_ignore_uri_user_options(void)
{
unsigned int ignore_uri_user_options;
@ -708,6 +726,9 @@ int ast_sip_initialize_sorcery_global(void)
ast_sorcery_object_field_register(sorcery, "global", "mwi_disable_initial_unsolicited",
DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED ? "yes" : "no",
OPT_BOOL_T, 1, FLDSET(struct global_config, mwi.disable_initial_unsolicited));
ast_sorcery_object_field_register(sorcery, "global", "allow_sending_180_after_183",
DEFAULT_ALLOW_SENDING_180_AFTER_183 ? "yes" : "no",
OPT_BOOL_T, 1, FLDSET(struct global_config, allow_sending_180_after_183));
ast_sorcery_object_field_register(sorcery, "global", "ignore_uri_user_options",
DEFAULT_IGNORE_URI_USER_OPTIONS ? "yes" : "no",
OPT_BOOL_T, 1, FLDSET(struct global_config, ignore_uri_user_options));

View File

@ -2030,6 +2030,17 @@
<configOption name="norefersub" default="yes">
<synopsis>Advertise support for RFC4488 REFER subscription suppression</synopsis>
</configOption>
<configOption name="allow_sending_180_after_183" default="no">
<synopsis>Allow 180 after 183</synopsis>
<description><para>
Allow Asterisk to send 180 Ringing to an endpoint
after 183 Session Progress has been send.
If disabled Asterisk will instead send only a
183 Session Progress to the endpoint.
(default: "no")
</para>
</description>
</configOption>
</configObject>
</configFile>
</configInfo>