[Asterisk-Users] Inconsistency with ANI and channel callerid

Gil Kloepfer astr-usr at kloepfer.org
Sun Jun 4 10:12:39 MST 2006


I've recently noticed some oddities in my CDR records.  In some cases
the original CallerID that I've set in the .conf file for the extension
showed-up in the CDR as the originating extension (on Zap/ devices on
the channel bank), and in other places it was the one that I set
using Set(CALLERID(num)=<something>) (SIP/ devices).

Digging around a little in the source (and doing some printing of stuff
in the dialplan), it appears as that:

   1.  The CDR prefers to use the ANI as the "from" extension, and if
       that doesn't exist, then use the CALLERID(num)

   2.  If you specify "callerid=" in the {sip,iax,mgcp,zaptel}.conf
       file, the ANI only gets set for Zap/, and I think MGCP/ and vpb/
       devices.

So my question:  Is this a bug or a feature?  Am I missing something?

It would seem that the right behavior would be one of consistency -- if
someone specifies the callerid= option in any of the channel .conf files,
then it should either set or not set ANI, but not behave differently for
different channels.

The reason this problem came to light is that we have both DID and non-DID
internal numbers.  The non-DID numbers can make outgoing calls to the
PSTN, and their outbound CallerID when hitting the PSTN is set to
our main reception desk.  What I'd LIKE to do is maintain the
originating number in the CDR so that we have a record of the
actual non-DID extension making outgoing calls, but set the reception
desk as the outbound CallerID on the PSTN.  What's happening now is
that this is working for Zap/ devices, but not for SIP/ devices because
of the problem noted above.

A workaround I could use would be to make a Macro that is something
like this:

[macro-ChangeCIDnum]
exten => s,1,GotoIf(${ISNULL(${CALLERID(ANI)})}?:aniset)
; If ANI isn't set, then set it to the current CALLERID(num) before
; we change the CALLERID(num)
exten => s,n,Set(CALLERID(ANI)=${CALLERID(num)})
; Now change the CALLERID(num)
exten => s,n(aniset),Set(CALLERID(num)=${ARG1})
exten => s,n,MacroExit

and use this every time I would normally Set(CALLERID(num)=<something>).

But this seems like the wrong thing to do.

Thanks in advance for any feedback.

---
Gil Kloepfer
astrepl at kloepfer.org



More information about the asterisk-users mailing list