From 7e8edd5e55eb086be7f97ec20c8c3383bba69d35 Mon Sep 17 00:00:00 2001
From: George Yang <george.yang@iopsys.eu>
Date: Thu, 21 Mar 2024 15:53:35 +0000
Subject: [PATCH] Remove the default terminationdigit '#'

This fixes the bug that '#' is not passed to SIP proxy transparently if it is not
configured as the termination digit.


(cherry picked from commit b1da9c76c706e6e02f8904c444ded28d3cbafe16)

4fbfe782 Remove the default terminationdigit '#'
---
 src/channels/chan_voicemngr.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c
index 81f5184..470de25 100644
--- a/src/channels/chan_voicemngr.c
+++ b/src/channels/chan_voicemngr.c
@@ -499,8 +499,8 @@ static const DTMF_CHARNAME_MAP dtmf_to_charname[] =
 	{EVENT_DTMFB, "DTMFB", 'B', 13},
 	{EVENT_DTMFC, "DTMFC", 'C', 14},
 	{EVENT_DTMFD, "DTMFD", 'D', 15},
-	{EVENT_DTMFH, "DTMFH", 0x23, 11}, //#
-	{EVENT_DTMFS, "DTMFS", 0x2A, 10}, //*
+	{EVENT_DTMFH, "DTMFH", '#', 11},
+	{EVENT_DTMFS, "DTMFS", '*', 10},
 	{EVENT_LAST,  "", '-', -1}
 };
 
@@ -2545,13 +2545,11 @@ static int handle_dialtone_timeout(const void *data)
 void handle_dtmf_calling(struct chan_voicemngr_subchannel *sub)
 {
 	struct chan_voicemngr_pvt *p = sub->parent;
-	char termination_digit;
+	char termination_digit = channel_config[p->line_id].terminationdigit;
 	int dtmfbuf_len = strlen(p->dtmfbuf);
 	char dtmf_last_char = p->dtmfbuf[(dtmfbuf_len - 1)];
 	char dtmf_one_before_last_char = p->dtmfbuf[(dtmfbuf_len > 1 ? dtmfbuf_len - 2 : 0)];
         
-	termination_digit = channel_config[p->line_id].terminationdigit?channel_config[p->line_id].terminationdigit:0x23;
-
 	if (ast_exists_extension(NULL, p->context_direct, p->dtmfbuf, 1, p->cid_num) && !ast_matchmore_extension(NULL, p->context_direct, p->dtmfbuf, 1, p->cid_num))
 	{
 		//We have a full match in the "direct" context, so have asterisk place a call immediately
@@ -2560,8 +2558,8 @@ void handle_dtmf_calling(struct chan_voicemngr_subchannel *sub)
 	}
 
 
-	else if (ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num) && dtmf_last_char == termination_digit
-                && dtmf_one_before_last_char != 0x2A) {
+	else if (termination_digit && dtmf_last_char == termination_digit && dtmf_one_before_last_char != '*'
+		&& ast_exists_extension(NULL, p->context, p->dtmfbuf, 1, p->cid_num)) {
 
                 ast_log(LOG_NOTICE, "Termination key %c is pressed during dialing\n",termination_digit);
                 int match = feature_access_code_match(p->dtmfbuf);
-- 
GitLab