[Asterisk-code-review] res_pjsip_session: Add overlap_context option. (asterisk[18])

George Joseph asteriskteam at digium.com
Mon Jan 30 08:45:58 CST 2023


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19836 )

Change subject: res_pjsip_session: Add overlap_context option.
......................................................................

res_pjsip_session: Add overlap_context option.

Adds the overlap_context option, which can be used
to explicitly specify a context to use for overlap
dialing extension matches, rather than forcibly
using the context configured for the endpoint.

ASTERISK-30262 #close

Change-Id: Ibbcd4a8b11402428a187fb56b8d4e7408774a0db
---
M configs/samples/pjsip.conf.sample
A contrib/ast-db-manage/config/versions/f261363a857f_add_overlap_context.py
A doc/CHANGES-staging/res_pjsip_session_overlap.txt
M include/asterisk/res_pjsip.h
M res/res_pjsip/pjsip_config.xml
M res/res_pjsip/pjsip_configuration.c
M res/res_pjsip/pjsip_manager.xml
M res/res_pjsip_session.c
8 files changed, 67 insertions(+), 2 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit




diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index 0a93cbe..572cf08 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -616,6 +616,8 @@
 ;aggregate_mwi=yes      ;  (default: "yes")
 ;allow= ; Media Codec s to allow (default: "")
 ;allow_overlap=yes ; Enable RFC3578 overlap dialing support. (default: "yes")
+;overlap_context=default ; Context to used for overlap dialing matches
+                         ; (default: same as context option)
 ;aors=  ; AoR s to be used with the endpoint (default: "")
 ;auth=  ; Authentication Object s associated with the endpoint (default: "")
 ;callerid=      ; CallerID information for the endpoint (default: "")
diff --git a/contrib/ast-db-manage/config/versions/f261363a857f_add_overlap_context.py b/contrib/ast-db-manage/config/versions/f261363a857f_add_overlap_context.py
new file mode 100644
index 0000000..e0ea297
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/f261363a857f_add_overlap_context.py
@@ -0,0 +1,21 @@
+"""add overlap_context
+
+Revision ID: f261363a857f
+Revises: 5a2247c957d2
+Create Date: 2022-12-09 13:58:48.622000
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'f261363a857f'
+down_revision = '5a2247c957d2'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    op.add_column('ps_endpoints', sa.Column('overlap_context', sa.String(80)))
+
+def downgrade():
+    op.drop_column('ps_endpoints', 'overlap_context')
diff --git a/doc/CHANGES-staging/res_pjsip_session_overlap.txt b/doc/CHANGES-staging/res_pjsip_session_overlap.txt
new file mode 100644
index 0000000..5523f3c
--- /dev/null
+++ b/doc/CHANGES-staging/res_pjsip_session_overlap.txt
@@ -0,0 +1,4 @@
+Subject: res_pjsip_session
+
+The overlap_context option now allows explicitly
+specifying a context to use for overlap dialing matches.
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index a49a56e..5b86d0f 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -1065,6 +1065,8 @@
 	AST_STRING_FIELD_EXTENDED(geoloc_incoming_call_profile);
 	/*! The name of the geoloc profile to apply when Asterisk sends a call to this endpoint */
 	AST_STRING_FIELD_EXTENDED(geoloc_outgoing_call_profile);
+	/*! The context to use for overlap dialing, if different from the endpoint's context */
+	AST_STRING_FIELD_EXTENDED(overlap_context);
 	/*! 100rel mode to use with this endpoint */
 	enum ast_sip_100rel_mode rel100;
 	/*! Send Advice-of-Charge messages */
diff --git a/res/res_pjsip/pjsip_config.xml b/res/res_pjsip/pjsip_config.xml
index 99ca645..bbbdd12 100644
--- a/res/res_pjsip/pjsip_config.xml
+++ b/res/res_pjsip/pjsip_config.xml
@@ -313,6 +313,16 @@
 				<configOption name="allow_overlap" default="yes">
 					<synopsis>Enable RFC3578 overlap dialing support.</synopsis>
 				</configOption>
+				<configOption name="overlap_context">
+					<synopsis>Dialplan context to use for RFC3578 overlap dialing.</synopsis>
+					<description>
+						<para>Dialplan context to use for overlap dialing extension matching.
+						If not specified, the context configured for the endpoint will be used.
+						If specified, the extensions/patterns in the specified context will be used
+						for determining if a full number has been received from the endpoint.
+						</para>
+					</description>
+				</configOption>
 				<configOption name="aors">
 					<synopsis>AoR(s) to be used with the endpoint</synopsis>
 					<description><para>
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index bb015d0..e101488 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -2229,6 +2229,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "asymmetric_rtp_codec", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, asymmetric_rtp_codec));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtcp_mux", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtcp_mux));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_overlap", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_overlap));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "overlap_context", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, overlap_context));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "refer_blind_progress", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, refer_blind_progress));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "notify_early_inuse_ringing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, notify_early_inuse_ringing));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_audio_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_audio_streams));
@@ -2427,6 +2428,10 @@
 		ao2_cleanup(endpoint);
 		return NULL;
 	}
+	if (ast_string_field_init_extended(endpoint, overlap_context)) {
+		ao2_cleanup(endpoint);
+		return NULL;
+	}
 
 	if (!(endpoint->media.codecs = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		ao2_cleanup(endpoint);
diff --git a/res/res_pjsip/pjsip_manager.xml b/res/res_pjsip/pjsip_manager.xml
index 810a5e3..475da8b 100644
--- a/res/res_pjsip/pjsip_manager.xml
+++ b/res/res_pjsip/pjsip_manager.xml
@@ -507,6 +507,9 @@
 				<parameter name="Allowoverlap">
 					<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_overlap']/synopsis/node())"/></para>
 				</parameter>
+				<parameter name="OverlapContext">
+					<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='overlap_context']/synopsis/node())"/></para>
+				</parameter>
 			</syntax>
 		</managerEventInstance>
 	</managerEvent>
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index e7ba3ed..ae2e0e4 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -3713,8 +3713,10 @@
 
 	fetch_callerid_num(session, rdata, cid_num, sizeof(cid_num));
 
+	/* If there's an overlap_context override specified, use that; otherwise, just use the endpoint's context */
+
 	if (!strcmp(session->exten, pickupexten) ||
-		ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, S_OR(cid_num, NULL))) {
+		ast_exists_extension(NULL, S_OR(session->endpoint->overlap_context, session->endpoint->context), session->exten, 1, S_OR(cid_num, NULL))) {
 		/*
 		 * Save off the INVITE Request-URI in case it is
 		 * needed: CHANNEL(pjsip,request_uri)
@@ -3729,7 +3731,7 @@
 	 */
 	if (session->endpoint->allow_overlap && (
 		!strncmp(session->exten, pickupexten, strlen(session->exten)) ||
-		ast_canmatch_extension(NULL, session->endpoint->context, session->exten, 1, S_OR(cid_num, NULL)))) {
+		ast_canmatch_extension(NULL, S_OR(session->endpoint->overlap_context, session->endpoint->context), session->exten, 1, S_OR(cid_num, NULL)))) {
 		/* Overlap partial match */
 		return SIP_GET_DEST_EXTEN_PARTIAL;
 	}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19836
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Ibbcd4a8b11402428a187fb56b8d4e7408774a0db
Gerrit-Change-Number: 19836
Gerrit-PatchSet: 2
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230130/ad36f594/attachment-0001.html>


More information about the asterisk-code-review mailing list