Identify incoming collect call in PJSIP

Dears,

I’m new to Asterisk and I don’t use it professionally, I’m learning because I like it and to use it in my home.

I have a fiber that gives me access to the internet and a telephone line. Internally the ONT has an ATA that provides the telephone line on an FXO port.
I disabled the SIP account on the ONT and configured it on Asterisk.

Everything is working, but I ran into a problem. How to identify collect calls???

I don’t want to permanently block the operator, as I’m thinking about creating a white list of numbers from which I will receive collect calls, but that’s later on. For now, I need to identify that the call that came in is collect and hang up.

I captured the SIP flow and was unable to identify absolutely any parameter that provides this information, below is the INVITE of an incoming collect call:

INVITE sip:0xxxxxxxxxx@192.168.xxx.xxx:5060;line=rzixxxx;ue-addr=10.xxx.xxx.xxx SIP/2.0
Via: SIP/2.0/UDP 10.xxx.xxx.xxx:5060;branch=z9hG4bK26gr170010xxxxxxxxxx.1
Call-ID: LU-1701558408xxxxxx-xxxxxxxx@imsxxx-xxx.mgmpxxxxxx.ims.oi.net.br
To: <sip:+55xxxxxxxxxx@ims.oi.net.br;user=phone>
From: <sip:+55xxxxxxxxxxx;cpc=priority@ims.oi.net.br;user=phone>;tag=62689ffe-656bb888xxxxxxxx-gm-pt-lucentPCSF-xxxxxx
CSeq: 1 INVITE
Allow: INVITE,BYE,REGISTER,ACK,OPTIONS,CANCEL,SUBSCRIBE,NOTIFY,INFO,REFER
Contact: <sip:+55xxxxxxxxx;cpc=priority@10.xxx.xxx.xxx:5060;x-afi=132;encoded-parm=QbkRBthOEgsTXgkTBA0HHiUrKz1CQEJLRkZNNgQVHVQsJW4pNS9qPCg5e35jJyIjxxxxxxxxxxxxxxxxxxxx;transport=udp>
Content-Type: application/sdp
Expires: 155
Max-Forwards: 67
P-Asserted-Identity: <sip:+55xxxxxxxxxxx;cpc=priority@ims.oi.net.br;user=phone>
Request-Disposition: no-fork
Timestamp: 25531
Content-Length: 181
P-Called-Party-ID: "+55xxxxxxxxxx" <sip:+55xxxxxxxxxx@ims.oi.net.br;user=phone>
CondorTrigger: term

v=0
o=LucentPCSF 70012xxxx 70012xxxx IN IP4 10.xxx.xxx.xxx
s=-
c=IN IP4 10.xxx.xxx.xxx
t=0 0
m=audio 12274 RTP/AVP 8 96
a=rtpmap:96 telephone-event/8000
a=ptime:20
a=maxptime:60

After the INVITE, the normal flow follows, nothing that identifies it as a collect call.

There is no point in expecting that the operator that provides the fiber and line will cooperate, nor even using the line directly at Asterisk or any other exchange, they support and make it as difficult as possible.

When I answer the collect call, I hear a characteristic announcement (it’s attached) that is mandatory for all collect calls in my country, so I thought of somehow identifying that audio and that way I would know that the call is collect. But how do I identify that audio?

It would have to be something that would not paralyze the call for analysis, preferably because it takes more than 15 seconds. I thought about using the TONE_DETECT function, but this is already too advanced for me and I didn’t find many examples about it, the documentation is also very superficial, at least for my level of knowledge. I ran some tests but got absolutely no results.

Could anyone help me? It can be using this function or with other ideas.

I’m using pure Asterisk, version 16.30.1, under Debian 10.7. PJSIP 2.12.1. I know that the Asterisk version is outdated, but it is working well and unless it is an impediment to solving this difficulty, I would like to continue with it for a while longer.

I really appreciate anyone who can help.

Best regards,

Vinicius

  1. What do you mean by “collect calls”?

  2. Going back to the original configuration with the ONT (whatever that is) and
    the FXO port - how do you identify “collect calls” then?

Antony.

Reversed charge. The OP seems to be saying that he can receive calls, which start with a standard voice announcement, and if he does not hang up the call immediately, he will be billed for the call.

Exactly.
Collect calls means the person receiving the call will make the payment.

  1. Collect calls means the person receiving the call will make the payment.

  2. ONT = Optical Network Terminal
    On analog PSTN lines, the identification of collect calls is carried out using a code sent together with the CallerID, however the FXO of this ONT does not provide this code. The only way to know that the call is chargeable is through the announcement (link in the initial post).

In my country these kind of calls do not exist. What about if someone has his voicemail answering? Does he have to pay for every call just because his voicemail box is answering the call?

Regarding your question, my best idea at the moment is to use something like WaitForDigits (after playing an announcement) in your dialplan and make the caller press a number to get connected.

EDIT
another idea is to play with the amd() function.

https://docs.asterisk.org/Asterisk_21_Documentation/API_Documentation/Dialplan_Applications/AMD/

Você não tem muito o que fazer se não souber usar a função TONEDETECT do asterisk, que talvez pudesse ajudar, mas eu não tenho certeza. No final do anúncio de chamada a cobrar, tem uns tons que são reproduzidos um a um, e você poderia pegar por exemplo a frequência e duração do penúltimo ou último tom e usar na função TONEDETECT para derrubar a chamada. Eu me lembro de ter estas frequencias anotadas em algum lugar, mas não estou em casa no momento.

outra coisa é ligar para a sua operadora e pedir que eles mesmos façam isso. não sei se ainda cobram por este serviço, mas na minha época de telefone fixo me cobravam uns 4 ou 5 reais.

try contact you provider and ask if they have an option to deny collect call
or have an option where you have to press a digit to accept

I don’t want to permanently block the operator, as I’m thinking about creating a white list of numbers from which I will receive collect calls, but that’s later on. For now, I need to identify that the call that came in is collect and hang up.

same => n,Set(TONE_DETECT(630,,g(hangup-cc,s,1))=)

Tentei com as frequências de 630Hz e 1081Hz (que aparecem no primeiro conjunto de sinais), nunca executa o contexto hangup-cc.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.