Skip to content

Commit 273ad73

Browse files
InterLinked1gtjoseph
authored andcommitted
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. 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.
1 parent 8462154 commit 273ad73

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

channels/chan_dahdi.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ static int my_callwait(void *pvt)
16451645
static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *caller)
16461646
{
16471647
struct dahdi_pvt *p = pvt;
1648+
struct analog_pvt *analog_p = p->sig_pvt;
16481649

16491650
ast_debug(2, "Starting cid spill\n");
16501651

@@ -1656,13 +1657,20 @@ static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *calle
16561657
if ((p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) {
16571658
int pres = ast_party_id_presentation(&caller->id);
16581659
if (cwcid == 0) {
1660+
/* Some CPE support additional parameters for on-hook Caller*ID,
1661+
* such as redirecting reason and call qualifier, so send those
1662+
* if available.
1663+
* I don't know of any CPE that supports this for Call Waiting (unfortunately),
1664+
* so don't send those for call waiting as that will just lengthen the CID spill
1665+
* for no good reason.
1666+
*/
16591667
p->cidlen = ast_callerid_full_generate(p->cidspill,
16601668
caller->id.name.str,
16611669
caller->id.number.str,
16621670
NULL,
1663-
-1,
1671+
analog_p->redirecting_reason,
16641672
pres,
1665-
0,
1673+
analog_p->call_qualifier,
16661674
CID_TYPE_MDMF,
16671675
AST_LAW(p));
16681676
} else {

channels/sig_analog.c

+15
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,8 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest
10731073
}
10741074

10751075
}
1076+
1077+
/* Name and Number */
10761078
n = ast_channel_connected(ast)->id.name.valid ? ast_channel_connected(ast)->id.name.str : NULL;
10771079
l = ast_channel_connected(ast)->id.number.valid ? ast_channel_connected(ast)->id.number.str : NULL;
10781080
if (l) {
@@ -1087,12 +1089,25 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest
10871089
}
10881090

10891091
if (p->use_callerid) {
1092+
const char *qual_var;
1093+
1094+
/* Caller ID Name and Number */
10901095
p->caller.id.name.str = p->lastcid_name;
10911096
p->caller.id.number.str = p->lastcid_num;
10921097
p->caller.id.name.valid = ast_channel_connected(ast)->id.name.valid;
10931098
p->caller.id.number.valid = ast_channel_connected(ast)->id.number.valid;
10941099
p->caller.id.name.presentation = ast_channel_connected(ast)->id.name.presentation;
10951100
p->caller.id.number.presentation = ast_channel_connected(ast)->id.number.presentation;
1101+
1102+
/* Redirecting Reason */
1103+
p->redirecting_reason = ast_channel_redirecting(ast)->from.number.valid ? ast_channel_redirecting(ast)->reason.code : -1;
1104+
1105+
/* Call Qualifier */
1106+
ast_channel_lock(ast);
1107+
/* XXX In the future, we may want to make this a CALLERID or CHANNEL property and fetch it from there. */
1108+
qual_var = pbx_builtin_getvar_helper(ast, "CALL_QUALIFIER");
1109+
p->call_qualifier = ast_true(qual_var) ? 1 : 0;
1110+
ast_channel_unlock(ast);
10961111
}
10971112

10981113
ast_setstate(ast, AST_STATE_RINGING);

channels/sig_analog.h

+3
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,15 @@ struct analog_pvt {
342342
* gives a positive reply.
343343
*/
344344
unsigned int callwaitcas:1;
345+
unsigned int call_qualifier:1; /*!< Call qualifier delivery */
345346

346347
char callwait_num[AST_MAX_EXTENSION];
347348
char callwait_name[AST_MAX_EXTENSION];
348349
char lastcid_num[AST_MAX_EXTENSION];
349350
char lastcid_name[AST_MAX_EXTENSION];
350351
struct ast_party_caller caller;
352+
int redirecting_reason; /*!< Redirecting reason */
353+
351354
int cidrings; /*!< Which ring to deliver CID on */
352355
char echorest[20];
353356
int polarity;

configs/samples/chan_dahdi.conf.sample

+9
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,15 @@ context=public
572572
;
573573
usecallerid=yes
574574
;
575+
; NOTE: If the CALL_QUALIFIER variable on the channel is set to 1,
576+
; the Stentor Call Qualifier parameter will be sent for Caller ID spills
577+
; using the Multiple Data Message Format (MDMF).
578+
; This is used by capable Caller ID units to activate the
579+
; "LDC" (Long Distance Call) indicator.
580+
; This variable is not automatically set anywhere. You are responsible
581+
; for setting it in the dialplan if you want to activate the indicator,
582+
; and you must have compatible CPE.
583+
;
575584
; Type of caller ID signalling in use
576585
; bell = bell202 as used in US (default)
577586
; v23 = v23 as used in the UK

funcs/func_callerid.c

+15
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@
182182
<para>Number Unavailable.</para>
183183
</enum>
184184
</enumlist>
185+
<variablelist>
186+
<variable name="CALL_QUALIFIER">
187+
<para>This is a special Caller ID-related variable
188+
that can be used to enable sending the Call Qualifier
189+
parameter in MDMF (Multiple Data Message Format)
190+
Caller ID spills.</para>
191+
<para>This variable is not automatically set by Asterisk.
192+
You are responsible for setting it if/when needed.</para>
193+
<para>Supporting Caller ID units will display the LDC
194+
(Long Distance Call) indicator when they receive this parameter.</para>
195+
<para>This option must be used with a channel driver
196+
that allows Asterisk to generate the Caller ID spill,
197+
which currently only includes <literal>chan_dahdi</literal>.</para>
198+
</variable>
199+
</variablelist>
185200
</description>
186201
</function>
187202
<function name="CONNECTEDLINE" language="en_US">

0 commit comments

Comments
 (0)