]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
sig_analog: Add fuller Caller ID support.
authorNaveen Albert <asterisk@phreaknet.org>
Thu, 18 May 2023 16:29:35 +0000 (16:29 +0000)
committerGeorge Joseph <gtjoseph@users.noreply.github.com>
Mon, 5 Jun 2023 18:27:52 +0000 (12:27 -0600)
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.

Resolves: #94
ASTERISK-30331

UserNote: Additional Caller ID properties are now supported on
incoming calls to FXS stations, namely the
redirecting reason and call qualifier.

channels/chan_dahdi.c
channels/sig_analog.c
channels/sig_analog.h
configs/samples/chan_dahdi.conf.sample
funcs/func_callerid.c

index 4e7aa5afad0cd4f3165e4dbcb7dd96f9718011db..fb860270de2a45c9a5e0258339149fd28e039718 100644 (file)
@@ -1645,6 +1645,7 @@ static int my_callwait(void *pvt)
 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");
 
@@ -1656,13 +1657,20 @@ static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *calle
        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 {
index 8d5ccd64fc7044865624ff7eb6ec6c2188d9c804..9addccbb89eb97b9da0f1ce2d41977fa55972619 100644 (file)
@@ -1073,6 +1073,8 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest
                        }
 
                }
+
+               /* 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,25 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest
                }
 
                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");
+                       p->call_qualifier = ast_true(qual_var) ? 1 : 0;
+                       ast_channel_unlock(ast);
                }
 
                ast_setstate(ast, AST_STATE_RINGING);
index 07e1cdd2aa1a7613c05074c8e495993b79891491..690326bfda90c955750b8078fe6db88d97b2e2fe 100644 (file)
@@ -342,12 +342,15 @@ struct analog_pvt {
         * 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;
index c54f482566715b4560e9e013bec08774ab1f75bc..2dadb31af949319c41a5869af35a2b63b9ba7e1e 100644 (file)
@@ -572,6 +572,15 @@ context=public
 ;
 usecallerid=yes
 ;
+; NOTE: If the CALL_QUALIFIER variable on the channel is set to 1,
+; the Stentor Call Qualifier parameter will be sent for Caller ID spills
+; using the Multiple Data Message Format (MDMF).
+; This is used by capable Caller ID units to activate the
+; "LDC" (Long Distance Call) indicator.
+; This variable is not automatically set anywhere. You are responsible
+; for setting it in the dialplan if you want to activate the indicator,
+; and you must have compatible CPE.
+;
 ; Type of caller ID signalling in use
 ;     bell     = bell202 as used in US (default)
 ;     v23      = v23 as used in the UK
index 448f54696d34a2f1804fec0ace1d4651cbf23b72..7ecf9f9c6e924558bc14eacb4dbebbdece135560 100644 (file)
                                        <para>Number Unavailable.</para>
                                </enum>
                        </enumlist>
+                       <variablelist>
+                               <variable name="CALL_QUALIFIER">
+                                       <para>This is a special Caller ID-related variable
+                                       that can be used to enable sending the Call Qualifier
+                                       parameter in MDMF (Multiple Data Message Format)
+                                       Caller ID spills.</para>
+                                       <para>This variable is not automatically set by Asterisk.
+                                       You are responsible for setting it if/when needed.</para>
+                                       <para>Supporting Caller ID units will display the LDC
+                                       (Long Distance Call) indicator when they receive this parameter.</para>
+                                       <para>This option must be used with a channel driver
+                                       that allows Asterisk to generate the Caller ID spill,
+                                       which currently only includes <literal>chan_dahdi</literal>.</para>
+                               </variable>
+                       </variablelist>
                </description>
        </function>
        <function name="CONNECTEDLINE" language="en_US">