[Asterisk-code-review] sig_analog: Add fuller Caller ID support. (asterisk[master])

N A asteriskteam at digium.com
Fri Nov 25 18:01:50 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19601 )


Change subject: sig_analog: Add fuller Caller ID support.
......................................................................

sig_analog: Add fuller Caller ID support.

A previous change, ASTERISK_29991, made it possible
to send additional Caller ID parameters that were
not previously supported.

This change adds support for analog DAHDI channels
to now be able to receive these parameters for
on-hook Caller ID, in order to enhance the usability
of CPE that support these parameters.

ASTERISK-30331 #close

Change-Id: I24a5a4df8d030729e9608f168b0b239dbda67039
---
M channels/chan_dahdi.c
M channels/sig_analog.c
M channels/sig_analog.h
A doc/CHANGES-staging/sig_analog_callerid.txt
4 files changed, 57 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/19601/1

diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 5607eb0..f0cbe73 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -1633,6 +1633,7 @@
 static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *caller)
 {
 	struct dahdi_pvt *p = pvt;
+	struct analog_pvt *analog_p = p->sig_pvt;
 
 	ast_debug(2, "Starting cid spill\n");
 
@@ -1644,13 +1645,20 @@
 	if ((p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) {
 		int pres = ast_party_id_presentation(&caller->id);
 		if (cwcid == 0) {
+			/* Some CPE support additional parameters for on-hook Caller*ID,
+			 * such as redirecting reason and call qualifier, so send those
+			 * if available.
+			 * I don't know of any CPE that supports this for Call Waiting (unfortunately),
+			 * so don't send those for call waiting as that will just lengthen the CID spill
+			 * for no good reason.
+			 */
 			p->cidlen = ast_callerid_full_generate(p->cidspill,
 				caller->id.name.str,
 				caller->id.number.str,
 				NULL,
-				-1,
+				analog_p->redirecting_reason,
 				pres,
-				0,
+				analog_p->call_qualifier,
 				CID_TYPE_MDMF,
 				AST_LAW(p));
 		} else {
diff --git a/channels/sig_analog.c b/channels/sig_analog.c
index 76ee645..7cffb42 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -1073,6 +1073,8 @@
 			}
 
 		}
+
+		/* Name and Number */
 		n = ast_channel_connected(ast)->id.name.valid ? ast_channel_connected(ast)->id.name.str : NULL;
 		l = ast_channel_connected(ast)->id.number.valid ? ast_channel_connected(ast)->id.number.str : NULL;
 		if (l) {
@@ -1087,12 +1089,29 @@
 		}
 
 		if (p->use_callerid) {
+			const char *qual_var;
+
+			/* Caller ID Name and Number */
 			p->caller.id.name.str = p->lastcid_name;
 			p->caller.id.number.str = p->lastcid_num;
 			p->caller.id.name.valid = ast_channel_connected(ast)->id.name.valid;
 			p->caller.id.number.valid = ast_channel_connected(ast)->id.number.valid;
 			p->caller.id.name.presentation = ast_channel_connected(ast)->id.name.presentation;
 			p->caller.id.number.presentation = ast_channel_connected(ast)->id.number.presentation;
+
+			/* Redirecting Reason */
+			p->redirecting_reason = ast_channel_redirecting(ast)->from.number.valid ? ast_channel_redirecting(ast)->reason.code : -1;
+
+			/* Call Qualifier */
+			ast_channel_lock(ast);
+			/* XXX In the future, we may want to make this a CALLERID or CHANNEL property and fetch it from there. */
+			qual_var = pbx_builtin_getvar_helper(ast, "CALL_QUALIFIER");
+			if (!ast_strlen_zero(qual_var) && !strcmp(qual_var, "1")) {
+				p->call_qualifier = 1;
+			} else {
+				p->call_qualifier = 0;
+			}
+			ast_channel_unlock(ast);
 		}
 
 		ast_setstate(ast, AST_STATE_RINGING);
diff --git a/channels/sig_analog.h b/channels/sig_analog.h
index 7e9acda..e36c043 100644
--- a/channels/sig_analog.h
+++ b/channels/sig_analog.h
@@ -334,12 +334,15 @@
 	 * gives a positive reply.
 	 */
 	unsigned int callwaitcas:1;
+	unsigned int call_qualifier:1;	/*!< Call qualifier delivery */
 
 	char callwait_num[AST_MAX_EXTENSION];
 	char callwait_name[AST_MAX_EXTENSION];
 	char lastcid_num[AST_MAX_EXTENSION];
 	char lastcid_name[AST_MAX_EXTENSION];
 	struct ast_party_caller caller;
+	int redirecting_reason;			/*!< Redirecting reason */
+
 	int cidrings;					/*!< Which ring to deliver CID on */
 	char echorest[20];
 	int polarity;
diff --git a/doc/CHANGES-staging/sig_analog_callerid.txt b/doc/CHANGES-staging/sig_analog_callerid.txt
new file mode 100644
index 0000000..45c1b68
--- /dev/null
+++ b/doc/CHANGES-staging/sig_analog_callerid.txt
@@ -0,0 +1,5 @@
+Subject: chan_dahdi
+
+Additional Caller ID properties are now supported
+on incoming calls to FXS stations, namely the
+redirecting reason and call qualifier.

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I24a5a4df8d030729e9608f168b0b239dbda67039
Gerrit-Change-Number: 19601
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221126/1d163ed1/attachment.html>


More information about the asterisk-code-review mailing list