Skip to content

Commit d1bec36

Browse files
InterLinked1gtjoseph
authored andcommitted
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
1 parent 1da489a commit d1bec36

File tree

8 files changed

+51
-2
lines changed

8 files changed

+51
-2
lines changed

configs/samples/pjsip.conf.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@
616616
;aggregate_mwi=yes ; (default: "yes")
617617
;allow= ; Media Codec s to allow (default: "")
618618
;allow_overlap=yes ; Enable RFC3578 overlap dialing support. (default: "yes")
619+
;overlap_context=default ; Context to used for overlap dialing matches
620+
; (default: same as context option)
619621
;aors= ; AoR s to be used with the endpoint (default: "")
620622
;auth= ; Authentication Object s associated with the endpoint (default: "")
621623
;callerid= ; CallerID information for the endpoint (default: "")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""add overlap_context
2+
3+
Revision ID: f261363a857f
4+
Revises: 5a2247c957d2
5+
Create Date: 2022-12-09 13:58:48.622000
6+
7+
"""
8+
9+
# revision identifiers, used by Alembic.
10+
revision = 'f261363a857f'
11+
down_revision = '5a2247c957d2'
12+
13+
from alembic import op
14+
import sqlalchemy as sa
15+
16+
17+
def upgrade():
18+
op.add_column('ps_endpoints', sa.Column('overlap_context', sa.String(80)))
19+
20+
def downgrade():
21+
op.drop_column('ps_endpoints', 'overlap_context')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Subject: res_pjsip_session
2+
3+
The overlap_context option now allows explicitly
4+
specifying a context to use for overlap dialing matches.

include/asterisk/res_pjsip.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,8 @@ struct ast_sip_endpoint {
10651065
AST_STRING_FIELD_EXTENDED(geoloc_incoming_call_profile);
10661066
/*! The name of the geoloc profile to apply when Asterisk sends a call to this endpoint */
10671067
AST_STRING_FIELD_EXTENDED(geoloc_outgoing_call_profile);
1068+
/*! The context to use for overlap dialing, if different from the endpoint's context */
1069+
AST_STRING_FIELD_EXTENDED(overlap_context);
10681070
/*! 100rel mode to use with this endpoint */
10691071
enum ast_sip_100rel_mode rel100;
10701072
/*! Send Advice-of-Charge messages */

res/res_pjsip/pjsip_config.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@
313313
<configOption name="allow_overlap" default="yes">
314314
<synopsis>Enable RFC3578 overlap dialing support.</synopsis>
315315
</configOption>
316+
<configOption name="overlap_context">
317+
<synopsis>Dialplan context to use for RFC3578 overlap dialing.</synopsis>
318+
<description>
319+
<para>Dialplan context to use for overlap dialing extension matching.
320+
If not specified, the context configured for the endpoint will be used.
321+
If specified, the extensions/patterns in the specified context will be used
322+
for determining if a full number has been received from the endpoint.
323+
</para>
324+
</description>
325+
</configOption>
316326
<configOption name="aors">
317327
<synopsis>AoR(s) to be used with the endpoint</synopsis>
318328
<description><para>

res/res_pjsip/pjsip_configuration.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,7 @@ int ast_res_pjsip_initialize_configuration(void)
22292229
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "asymmetric_rtp_codec", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, asymmetric_rtp_codec));
22302230
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtcp_mux", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtcp_mux));
22312231
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_overlap", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_overlap));
2232+
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "overlap_context", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, overlap_context));
22322233
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "refer_blind_progress", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, refer_blind_progress));
22332234
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));
22342235
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 @@ void *ast_sip_endpoint_alloc(const char *name)
24272428
ao2_cleanup(endpoint);
24282429
return NULL;
24292430
}
2431+
if (ast_string_field_init_extended(endpoint, overlap_context)) {
2432+
ao2_cleanup(endpoint);
2433+
return NULL;
2434+
}
24302435

24312436
if (!(endpoint->media.codecs = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
24322437
ao2_cleanup(endpoint);

res/res_pjsip/pjsip_manager.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@
507507
<parameter name="Allowoverlap">
508508
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_overlap']/synopsis/node())"/></para>
509509
</parameter>
510+
<parameter name="OverlapContext">
511+
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='overlap_context']/synopsis/node())"/></para>
512+
</parameter>
510513
</syntax>
511514
</managerEventInstance>
512515
</managerEvent>

res/res_pjsip_session.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3713,8 +3713,10 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
37133713

37143714
fetch_callerid_num(session, rdata, cid_num, sizeof(cid_num));
37153715

3716+
/* If there's an overlap_context override specified, use that; otherwise, just use the endpoint's context */
3717+
37163718
if (!strcmp(session->exten, pickupexten) ||
3717-
ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, S_OR(cid_num, NULL))) {
3719+
ast_exists_extension(NULL, S_OR(session->endpoint->overlap_context, session->endpoint->context), session->exten, 1, S_OR(cid_num, NULL))) {
37183720
/*
37193721
* Save off the INVITE Request-URI in case it is
37203722
* needed: CHANNEL(pjsip,request_uri)
@@ -3729,7 +3731,7 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
37293731
*/
37303732
if (session->endpoint->allow_overlap && (
37313733
!strncmp(session->exten, pickupexten, strlen(session->exten)) ||
3732-
ast_canmatch_extension(NULL, session->endpoint->context, session->exten, 1, S_OR(cid_num, NULL)))) {
3734+
ast_canmatch_extension(NULL, S_OR(session->endpoint->overlap_context, session->endpoint->context), session->exten, 1, S_OR(cid_num, NULL)))) {
37333735
/* Overlap partial match */
37343736
return SIP_GET_DEST_EXTEN_PARTIAL;
37353737
}

0 commit comments

Comments
 (0)