Where does Asterisk get CallerID? [SOLVED]

I got a SPA-3102 with a pre-configured setup to a VoIP provider. When there is a incoming call, the telephone connected to it shows the correct Caller’s name and number.

Now I try to setup this as a SIP trunk in my Asterisk box. But I can’t manage to let the Asterisk get the correct Caller name and number. (The other SIP trunks works fine though).

To trouble shooting, I had these lines:

[from-trunk] exten => xxxxxx5333,1,NoOp(SIP HEADER FROM = ${SIP_HEADER(FROM)}) exten => xxxxxx5333,n,NoOp(SIP HEADER TO = ${SIP_HEADER(TO)}) exten => xxxxxx5333,n,NoOp(>>>>>>>>>>>The CallerName is ${CALLERID(name)}) exten => xxxxxx5333,n,NoOp(>>>>>>>>>>>The CallerNumber is ${CALLERID(num)}) .......

in my sip.conf

[VSP1]
username=xxxxxx5333
authuser=xxxxxx5333
type=friend
secret=password
insecure=port,invite
canreinvite=yes
host=my.vsp.com
context=from-trunk
callerid="My Name" <xxxxxx5333>

When i make a test call, I always got ${CALLERID(num)}=xxxxxx5333 and ${CALLERID(name)}=“My Name”(these are defined in sip.conf as callerid). It doesn’t show the caller’s name and number!

But I can clearly see in the SIP INVITE From Header, there is
From: "NameOfTheCaller"sip:6042885555@208.xxx.xxx.xxx;tag=11014dd0-13c4-4bc9285-bbaf206-7eaf7ad0
(tcpdump also proved this header information has been received)

So my question here is: Where does Asterisk get CallerID number from? Does it get from the SIP INVITE? Why my context can’t show the proper caller information?

Right now I am using a work around to CUT out the CALLERID(num) and CALLERID(name). But that doesn’t work very well. The wrong info ends up at CDR.

BTW, I am using Asterisk 1.4.29.

Please help. Thanks.

Try callerid= asreceived maybe?

Thank you,batrams for the help. I’ll test it tonight and report back.

I just tried and it partially works. The CALLERID(num) shows the correct caller’s number. But CALLERID(name) is always “asreceived”.

Then I also tried to comment out this “callerid=” line. And now everything is WORKING!

I can’t believe it. I tried to comment out that line and that broke the outgoing call(I guess there is some kind of authentication involved. ??). Any today it just works!

I guess I can just live with this.
Thanks for the help.

Cheers!

callerid=asreceive is only for ZAP or DAHDI channels - and OP have done a good job to not use it.
if you specify a callerid in sip.conf it will overwrite whatever it is received on the call - and exactly this is happened on this specific thread.

my 2 cents,
Ioan.