summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
diff options
context:
space:
mode:
authorRichard Begg <asterisk@meric.id.au>2017-03-15 08:45:06 +1100
committerJoshua Colp <jcolp@digium.com>2017-03-22 11:25:07 +0000
commit398e5ec16c5b919e17708e26d2e045c389afbd1c (patch)
tree065c960b31c2692dc82dfb42352b5dec166b097d /res/res_pjsip_session.c
parentfdea3698527495c940e03a45df03621c7a9a876c (diff)
res_pjsip_session: Enable RFC3578 overlap dialing support.
Support for RFC3578 overlap dialling (i.e. 484 Response to partially matched destinations) as currently provided by chan_sip is missing from res_pjsip. This patch adds a new endpoint attribute (allow_overlap) [defaults to yes] which when set to yes enables 484 responses to partial destination matches rather than the current 404. ASTERISK-26864 Change-Id: Iea444da3ee7c7d4f1fde1d01d138a3d7b0fe40f6
Diffstat (limited to 'res/res_pjsip_session.c')
-rw-r--r--res/res_pjsip_session.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index efdce8aa2..53841c44a 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1984,10 +1984,17 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
return SIP_GET_DEST_EXTEN_FOUND;
}
- /* XXX In reality, we'll likely have further options so that partial matches
- * can be indicated here, but for getting something up and running, we're going
- * to return a "not exists" error here.
+
+ /*
+ * Check for partial match via overlap dialling (if enabled)
*/
+ if (session->endpoint->allow_overlap && (
+ !strncmp(session->exten, pickupexten, strlen(session->exten)) ||
+ ast_canmatch_extension(NULL, session->endpoint->context, session->exten, 1, NULL))) {
+ /* Overlap partial match */
+ return SIP_GET_DEST_EXTEN_PARTIAL;
+ }
+
return SIP_GET_DEST_EXTEN_NOT_FOUND;
}
@@ -2104,8 +2111,17 @@ static int new_invite(void *data)
pjsip_inv_terminate(invite->session->inv_session, 416, PJ_TRUE);
}
goto end;
- case SIP_GET_DEST_EXTEN_NOT_FOUND:
case SIP_GET_DEST_EXTEN_PARTIAL:
+ ast_debug(1, "Call from '%s' (%s:%s:%d) to extension '%s' - partial match\n", ast_sorcery_object_get_id(invite->session->endpoint),
+ invite->rdata->tp_info.transport->type_name, invite->rdata->pkt_info.src_name, invite->rdata->pkt_info.src_port, invite->session->exten);
+
+ if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 484, NULL, NULL, &tdata) == PJ_SUCCESS) {
+ ast_sip_session_send_response(invite->session, tdata);
+ } else {
+ pjsip_inv_terminate(invite->session->inv_session, 484, PJ_TRUE);
+ }
+ goto end;
+ case SIP_GET_DEST_EXTEN_NOT_FOUND:
default:
ast_log(LOG_NOTICE, "Call from '%s' (%s:%s:%d) to extension '%s' rejected because extension not found in context '%s'.\n",
ast_sorcery_object_get_id(invite->session->endpoint), invite->rdata->tp_info.transport->type_name, invite->rdata->pkt_info.src_name,