From 0d6003fa9a2afb21c8953d5ac7238ea83412086d Mon Sep 17 00:00:00 2001
From: Naveen Albert <asterisk@phreaknet.org>
Date: Mon, 17 Oct 2022 00:33:44 +0000
Subject: [PATCH] res_pjsip_session.c: Map empty extensions in INVITEs to s.

Some SIP devices use an empty extension for PLAR functionality.

Rather than rejecting these empty extensions, we now use the s
extension for such calls to mirror the existing PLAR functionality
in Asterisk (e.g. chan_dahdi).

ASTERISK-30265 #close

Change-Id: I0861a405cd49bbbf532b52f7b47f0e2810832590
---
 res/res_pjsip_session.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index a7bde0da4e..67dcdf50d1 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -3665,6 +3665,11 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s
 	}
 
 	ast_copy_pj_str(session->exten, ast_sip_pjsip_uri_get_username(ruri), sizeof(session->exten));
+	if (ast_strlen_zero(session->exten)) {
+		/* Some SIP devices send an empty extension for PLAR: this should map to s */
+		ast_debug(1, "RURI contains no user portion: defaulting to extension 's'\n");
+		ast_copy_string(session->exten, "s", sizeof(session->exten));
+	}
 
 	/*
 	 * We may want to match in the dialplan without any user
-- 
GitLab