Provider sends CID only in "Contact:" header. How to configure FreePBX to take CID from it?

freepbx
configuration
Tags: #<Tag:0x00007f7025d77de0> #<Tag:0x00007f7025d77ae8>

(Alexey) #1

Provider sends CID only in “Contact:” header, not “From:”
“From:” is filled as “anonymous.”
Here is example:

    172.16.1.200.sip > my-sip1.sip: SIP, length: 984
    INVITE sip:+73439144003@10.66.53.34:5060;line=zyjlrii SIP/2.0
    Via: SIP/2.0/UDP 172.16.1.200:5060;branch=z9hG4bKer3rgewezrrkl1zllrrkk3lx0T36093
    Record-Route: <sip:172.16.1.200:5060;transport=udp;lr>
    Call-ID: asbci8a2j0agijz0r21x3pr8ap2lv1gi2lrp@ATS.ektb-ats01.ektb.ims.u-tel.ru.13
    From: "Anonymous"<sip:anonymous@anonymous.invalid>;tag=sbc04062zrxhhzr-CC-13
    To: <sip:+73439144003@172.16.1.200:5060;transport=udp;user=phone>
    CSeq: 1 INVITE
    Allow: INVITE,ACK,BYE,CANCEL,UPDATE,INFO,PRACK,NOTIFY,REFER,SUBSCRIBE,OPTIONS,MESSAGE
    Contact: <sip:+73439121963@172.16.1.200:5060;user=phone>
    Max-Forwards: 26
    Supported: 100rel,timer
    Session-Expires: 1800
    Min-SE: 600
    P-Called-Party-ID: <tel:+73439144003>
    Content-Length: 222
    Content-Type: application/sdp

FreePBX displays such calls as “Anonymous”

How to configure FreePBX/Asterisk to take CID from “Contact:” header, not “From:”?


(Daniel Friedman) #2

Hello @arti_crb,

Do you use a SIP or PJSIP trunk with your provider?

Thank you,

Daniel Friedman
Trixton LTD.


#3

Not tested, but I hope this is close:

For a chan_sip trunk, add to /etc/asterisk/extensions_custom.conf :

[from-trunk-fixcid]
exten => _.,1,Set(CALLERID(num)=${CUT(CUT(SIP_HEADER(Contact),@,1),:,2)}) 
exten => _.,n,Goto(from-trunk,${EXTEN},1)

Or for pjsip:

[from-trunk-fixcid]
exten => _.,1,Set(CALLERID(num)=${CUT(CUT(PJSIP_HEADER(read,Contact),@,1),:,2)}) 
exten => _.,n,Goto(from-trunk,${EXTEN},1)

Then change context for your trunk to from-trunk-fixcid


(Lorne Gaetz) #4

@Stewart1 has the fix. For ideas on how to combine the two methods to a single context, check the built in context from-pstn-toheader

What’s going on with this provider? Do all calls arrive like that or just some?


(Joshua C. Colp) #5

Depending on the relationship it honestly feels as though they may be leaking information that is supposed to be withheld, as the call is seemingly supposed to be anonymous. The information being in the Contact header (which isn’t supposed to be used for callerid) would be a coincidence. Coincidence is probably the wrong word. More like the SIP server is likely putting the callerid into the Contact header and disregarding any presentation information (that it is anonymous/withheld).


(Alexey) #6

Hello

I’m using PJSIP trunk.

Thank you.


(Alexey) #7

Thank you, @Stewart1 and @lgaetz

I’ll test your fix ASAP.

I was hoping, such provider’s behavior occurs often, but apparently I was wrong.

@jcolp says about provider

Maybe it’s an artefacts, when provider had a paid service (“Caller ID”), but I havn’t any information about it.


#8

You didn’t answer the question whether this happens on all inbound calls or just some.


(Alexey) #9

I think all calls are the same.
I tried mobile calls, landline and SIP. No difference.


#10

Your VoIP provider is broken. You should report this issue to them. If they try to sell you caller ID service, they suck. Find another provider. No one charges for numeric caller ID.


(Lorne Gaetz) #11

Here in NANP land, years ago I recall reading something about those with toll free DIDs being entitled to CID (even on anonymous calls) since they are the party footing the bill for the call. But I have never actually seen it in practice.


#12

That is a legacy goes all the way back to WATS numbers

But ANI is not exactly the same as CLID and WATS numbers always ended up on ‘landline’ numbers


#13

My TF numbers with Vitelity and Alcazar deliver blocked CIDs with no issue.

But I did have a problem once with Vitelity. A few years ago, blocked numbers suddenly stopped coming in. I opened a ticket and they explained that they had raised the rate (for small potatoes like me) to $0.024 and to grandfather me at $0.019 they moved me to another carrier that didn’t deliver blocked numbers. I was offered three choices:

  1. Agree to the new rate and they would return to the old carrier (XO).
  2. Get the old rate with XO by limiting coverage to US48.
  3. Do nothing and blocked numbers won’t be delivered.

I chose option 2.

A couple of years later, Vitelity switched to a new scheme where there are different rates for US48, HI, AK, Canada, etc. Users can enable each of these on the portal.


(Alexey) #14

@Stewart1, many thanks :+1:
It’s works!
Now I have:

[from-trunk-fixcid]
exten => _.,1,Set(CALLERID(num)=${CUT(CUT(PJSIP_HEADER(read,Contact),@,1),:,2)}).
exten => _.,n,Set(CALLERID(name)=${CUT(CUT(PJSIP_HEADER(read,Contact),@,1),:,2)}).
exten => _.,n,Goto(from-pstn,${EXTEN},1)

Yes, it’s almost good.

CDR report now says only one field “anonymous”: ANI. I

What else I must fill to totally eliminate “anonymous” in CDR?


#15

I don’t believe that the ANI column displays by default. If you have customized the columns, either remove ANI from the list, or populate CALLERID(ani) with something useful.

I suppose you could write it from the Contact header (same as you are doing for num and name), but that would just clutter the report with redundant information.