Link to home
Start Free TrialLog in
Avatar of Marius Kaizerman
Marius KaizermanFlag for Israel

asked on

Asterisk - incoming caller id

Hi,

Running Asterisk 1.8.11, two trunks connected.
When receiveing calls, the caller id shown is the trunk's DID number, and not the
real caller number.

The provider says that he sends the caller id information in the sip header, and when looking at the console while receiving a call, I can see it there.

The question is - how can I get the caller id from the sip header and make it appear on the extensions, as it should be ?

Thanks,
Marius.
Avatar of Phonebuff
Phonebuff
Flag of United States of America image

@Marius.

    What ISO did you build from,  FreePBX version and what phones are you using ?
Avatar of Marius Kaizerman

ASKER

Hi,

The ISO is AsteriskNow 2.0.2 32bit, FreePBX 2.10.0rc1-1 and Cisco 504G phones (although it's the same issue with softphones either).

What I need is a way to get the caller id info from the sip header and and set it to whatever extension is getting the call.

Thanks.
If you can see the callerid on the console then there must be a dialplan error causing it to be overridden. Or maybe what you are seeing is not actually the callerid.
Can you capture the SIP INVITE header. The callerid can be provided in the FROM header but also in the Remote-Party-ID or the P-Asserted-ID header. If either of these additional headers are provided you can get asterisk to recognize and trust them.
Hi,

Thanks for the answer and sorry for the delay in my reply, I wanted to do some research in order to supply enough information.

So, here's my findings:

On an INCOMING call, this is the what I see (only the relevant part showed):

Executing [s@custom-get-did-from-header:1] Goto("SIP/call-out-00000a92", "from-trunk,73862,1") in new stack
    -- Goto (from-trunk,73862,1)
    -- Executing [73862@from-trunk:1] Set("SIP/call-out-00000a92", "__FROM_DID=73862") in new stack
    -- Executing [73862@from-trunk:2] Gosub("SIP/call-out-00000a92", "app-blacklist-check,s,1()") in new stack
    -- Executing [s@app-blacklist-check:1] GotoIf("SIP/call-out-00000a92", "0?blacklisted") in new stack
    -- Executing [s@app-blacklist-check:2] Set("SIP/call-out-00000a92", "CALLED_BLACKLIST=1") in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/call-out-00000a92", "") in new stack
    -- Executing [73862@from-trunk:3] Set("SIP/call-out-00000a92", "__REC_POLICY_MODE=always") in new stack
    -- Executing [73862@from-trunk:4] Set("SIP/call-out-00000a92", "CDR(did)=73862") in new stack
    -- Executing [73862@from-trunk:5] ExecIf("SIP/call-out-00000a92", "1 ?Set(CALLERID(name)=XYXYXYXYXYXY)") in new stack

If you'll look at the last line - XYXYXYXYXYXY (which I changed from the real phone number) represents the CALLER ID, and this number is shown, no matter who calls in. This is of course not the real caller id of the caller, but the MY phone number.

When activating SIP DEBUG, I also see the headers, and here lies the REAL caller id of the caller:

SIP/2.0 200 OK
Via: SIP/2.0/UDP 1.2.2.1;branch=z9hG4bK174a.81214903.0;received=1.2.2.1;rport=5060
Via: SIP/2.0/UDP 1.2.2.1:5060;branch=z9hG4bK4a5fb90c;rport=5060
Record-Route: <sip:1.2.2.1;lr=on;ftag=as01f8b69e>
From: "+123456789" <sip:+123456789@sip.provider.com>;tag=as01f8b69e
To: <sip:73862@1.2.2.1>;tag=as2e44bb48
Call-ID: 19960d8b578c715a17895bdc089c631e@sip.provider.com
CSeq: 102 INVITE
erver: FPBX-2.10.0rc1(1.8.11)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Contact: <sip:s@10.0.11.2:5060>
Content-Type: application/sdp
Content-Length: 258

If you'll look at the line beginning with "FROM", the number "123456789" (which I've changed from the real number) is the REAL caller id.

My question is how can I see the number in this field as caller id ?

Thanks,
Marius/
You are setting CALLERID(name) but you should be setting CALLERID(number)
Hi,

How can I fix that ?

Thanks,
Marius.
The correct callerid should be set automatically when he call comes in. Have you tried adding something like the following to the dialplan to help debug.
Noop(callerid is ${CALLERID(number)})

You might also wish to ask your provider if hey support the remote-party-id sip header as you can then set trustrpid= in sip.conf to get asterisk to accept it. It works better for transferring the callerid name, number, and presentation.
I've just tried:
Noop(callerid is ${CALLERID(number)})

And now I'm getting in addition to the name also this line:
-- Executing [s@macro-user-callerid:25] Set("SIP/call-out-00000000", "CALLERID(number)=XYXYXYXYXY") in new stack

the XYXYXYXYXY which represents the caller id is still my number and NOT the the real caller number. It is the same number shown in the CALLERID(name) field.


Regarding the remote-party-id - yes, they do support it.
And I do have trustrpid=yes and sendrpid=yes in sip.conf, but it's not helping.
Can you post the contents of sip.conf for the trunk link (remove any passwords). You need to make sure the callerid is not specified there.
Two trunks:

[call-out]  
disallow=all
type=peer        
username=removed      
fromuser=removed    
secret=removed
host=sip.provider.com
port=6060
context=custom-get-did-from-header
;context=from-trunk
qualify=yes
insecure=invite,port
allow=g729    
trustrpid=yes        
sendrpid=yes

[call-out_copy_2]
disallow=all
username=removed
type=friend
secret=removed
port=6060
insecure=invite,port
host=sip.provider.com
fromuser=removed
allow=g729
qualify=yes
trusrpid=yes
sendrpid=yes
context=from-trunk-sip-call-out_copy_2
ASKER CERTIFIED SOLUTION
Avatar of grblades
grblades
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial