Summary:ASTERISK-19385: "Callerid:" in call-files and Asterisk Manager doesn't work
Reporter:ornix (ornix)Labels:
Date Opened:2012-02-18 00:44:44.000-0600Date Closed:2012-02-27 17:44:19.000-0600
Versions: Frequency of
must be completed before resolvingASTERISK-19128 Asterisk 1.8.10 Blockers
must be completed before resolvingASTERISK-19129 Asterisk 10.2.0 Blockers
is duplicated byASTERISK-19270 CallerID missing on local channel
Environment:Debian 6.0, 2.6.38-bpo.2-686Attachments:( 0) callerid.diff
Description:I do callback with the following call-file:

Channel: Local/2487305@qqq/n
Callerid: 2487305 <2487305>
Context: callback
Extension: s
MaxRetries: 3
Retrytime: 5
WaitTime: 60
Priority: 1

exten => s,1,Answer()
exten => s,n,NoOp(${CALLERID(all)})
exten => s,n,Hangup()

console-log in 1.8.10rc2:
      > Channel Local/2487305@qqq-55d1;1 was answered.
   -- Executing [s@callback:1] Answer("Local/2487305@qqq-55d1;1", "") in new stack
   -- Executing [s@callback:2] NoOp("Local/2487305@qqq-55d1;1", ""Unknown" <>") in new stack
   -- Executing [s@callback:3] Hangup("Local/2487305@qqq-55d1;1", "") in new stack
 == Spawn extension (callback, s, 3) exited non-zero on 'Local/2487305@qqq-55d1;1'

console-log in
    > Channel Local/2487305@qqq-ac03;1 was answered.
   -- Executing [s@callback:1] Answer("Local/2487305@qqq-ac03;1", "") in new stack
   -- Executing [s@callback:2] NoOp("Local/2487305@qqq-ac03;1", ""Unknown" <2487305>") in new stack
   -- Executing [s@callback:3] Hangup("Local/2487305@qqq-ac03;1", "") in new stack
 == Spawn extension (callback, s, 3) exited non-zero on 'Local/2487305@qqq-ac03;1'

CALLERID(num) in 1.8.10rc2 is empty. The call-file and dialplan are the same in both versions.
Comments:By: Nikola Ciprich (nikola.ciprich) 2012-02-21 03:50:29.781-0600

same problem here for calls initiated using AMI Originate..

By: Filip Frank (frenk77) 2012-02-22 14:17:25.043-0600

I have same problem with Originated call over AMI.

By: Matt Jordan (mjordan) 2012-02-23 11:25:12.718-0600

What happens if, in the call file, you use:

Callerid: "2487305" <2487305>

By: ornix (ornix) 2012-02-25 00:47:49.729-0600

The same. CALLERID is empty.

By: Matt Riddell (zx81) 2012-02-26 16:08:07.051-0600

Same here with Asterisk Manager originated call - I tried with CallerID: 123 as well as CallerID: 123 <123>

This is quite a problem for us.

By: Matt Riddell (zx81) 2012-02-26 16:25:30.654-0600

Ok, so,here we go - I'll comment as I approach the solution.

Revision 348339 works
Revision 349339 does not work

So we're down to a 1000 revision window.

By: Matt Riddell (zx81) 2012-02-26 16:29:24.261-0600

Revision 348339 works
Revision 348539 doesn't work

200 revision window

By: Matt Riddell (zx81) 2012-02-26 16:30:47.958-0600

Revision 348439 works
Revision 348539 doesn't work

100 revision window

By: Matt Riddell (zx81) 2012-02-26 16:36:26.285-0600

348463 does work
348464 doesn't work

Commit that broke it: [asterisk-commits] rmudgett: branch 1.8 r348464 - in /branches/1.8/main: channel.c features.c

Looks like the bit:

* Remove calls to ast_set_callerid() in __ast_request_and_dial() and
ast_call_forward() because the set information is for the wrong direction.

Will create a patch for latest 1.8

By: Matt Riddell (zx81) 2012-02-26 17:05:36.988-0600

Works for me:
Index: main/channel.c
--- main/channel.c      (revision 356880)
+++ main/channel.c      (working copy)
@@ -5331,7 +5331,11 @@
               if (oh->vars) {
                       ast_set_variables(chan, oh->vars);
+               /* XXX why is this necessary, for the parent_channel perhaps ? */
               if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
+                       ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
+               }
+               if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
                        * Use the oh values instead of the function parameters for the
                        * outgoing CallerID.

By: Matt Riddell (zx81) 2012-02-26 17:06:50.493-0600

Actually I think the problem might be the deletion of the line:

ast_set_callerid(chan, cid_num, cid_name, cid_num);

At the end of __ast_request_and_dial

By the looks of it he was going to set it at the end but removed the code that did it.

Anyway the above works for me.

By: Matt Riddell (zx81) 2012-02-26 17:09:59.603-0600

[^callerid.diff] "Works for me"

By: Matt Jordan (mjordan) 2012-02-27 15:58:17.476-0600

Thanks for hunting this down.  We'll make sure this is fixed in the next RC of 1.8.10 and 10.2.0

By: Matt Jordan (mjordan) 2012-02-28 11:44:49.196-0600

Just as an aside, the patch that went into 1.8.10/10.2.0 is slightly different, in that we set the caller ID of the outbound channel regardless of whether or not those values come from parameters passed to the function or come from an outgoing_handler struct.

By: Matt Riddell (zx81) 2012-02-28 17:40:26.519-0600

Yeah I saw that - I would have done the same but I wasn't sure about setting it without checking that it wasn't a zero length