[SOLVED] - Can't set ANI when the DAHDI incoming call has an empty CallerID

Hi community,

I’m running Asterisk 13.7.2 with a DAHDI card for incoming calls. When a call comes in and the ANI is blank (private number), I want to set the CALLERID name to “Private Number” (or some other thing).

Currently, the IP Phone shows “asterisk” in the display (probably because the From and/or Contact headers in the invite say so):

INVITE sip:687@192.168.4.87:5061 SIP/2.0
Via: SIP/2.0/UDP 192.168.4.170:5060;rport;branch=z9hG4bKPjf24942bb-3f6f-45d2-856d-eee6927b8673
From: sip:asterisk@119.31.226.70;tag=f9560bd9-5da8-40ee-8c6f-9e533c854aeb
To: sip:687@192.168.4.87
Contact: sip:asterisk@192.168.4.170:5060
Call-ID: fcb85bbd-517c-41f3-8575-5d64b970c21b
CSeq: 4116 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.7.2
Content-Type: application/sdp
Content-Length: 287

I tried setting the CALLERID like this:

exten => 12345678,1,Verbose(“Incoming private”)
same => n,Set(CALLERID(name)=Private)
same => n,Dial(PJSIP/687)

But the display on the phone keeps saying “asterisk”. If the ANI in the incoming call is not empty, then the Set(CALLERID(name)=Private) line does its job and changes the name correctly.

The output of the verbose log is as follows:

-- Executing [12345678@from_pstn:1] Verbose("DAHDI/i1/-a1", ""Incoming Private"") in new stack

NoOp
– Executing [12345678@from_pstn:2] Set(“DAHDI/i1/-a1”, “CALLERID(name)=Private”) in new stack
– Executing [12345678@from_pstn:3] Dial(“DAHDI/i1/-a1”, “PJSIP/687”) in new stack

Can anyone help me identify why the CALLERID is not changing tha ANI when it’s blank?

Thanks

Please use pre-formatted text, otherwise it is treated as HTML and the From and To headers are lost.

My guess is that this is because privacy is set on the number.

I just added the Privacy header in the SIP channel and set the value to off but unfortunately I still get the same problem:

INVITE sip:687@192.168.4.87:5061 SIP/2.0
Via: SIP/2.0/UDP 192.168.4.170:5060;rport;branch=z9hG4bKPj0a230e1a-58fc-449c-b8cb-d11176187105
From: ;tag=df8cfe64-a1e7-406f-84a0-161eec9a28cc
To: 
Contact: 
Call-ID: 1352dc06-c197-4531-9adb-1aac874d9f8e
CSeq: 1083 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Privacy: off
Max-Forwards: 70
User-Agent: Asterisk PBX 13.7.2
Content-Type: application/sdp
Content-Length:   285

I was talking about https://wiki.asterisk.org/wiki/display/AST/Function_CALLERPRES

thanks david551

I checked the link and CALLERPRES has been deprecated in favour of CALLERID(name-pres). I added these lines:

[handler]
exten => private,1,Set(PJSIP_HEADER(Add,Privacy)=off)
same => n,Set(CALLERID(name-pres)=allowed)
same => n,Set(CALLERID(name)=Private)

and called this from the Dial Application so it would apply to the PJSIP channel but still no luck

Ok. I got the problem solved so I thought of sharing with everyone in case someone else has the same problem.

The setting that needs to be changed is CALLERID(pres) which is set to “prohib” when there’s no callerid information.

I entered the following code:

exten => s,1,GoToIf($[CALLERID(pres)==prohib]?private:nonprivate)

same => n(private),Set(CALLERID(pres)=allowed_passed_screen)
same => n,Set(CID=Private Number)
same => n,Return(${CID})

same => n(nonprivate),Set(CID=${CALLERID(num)})
same => n,Return(${CID})

and problem fixed