Detect from which number the forwarded call is coming from

Status
Not open for further replies.

Fede

Member
Oct 4, 2020
35
1
6
37
Italy
Hello everyone! ;)
What I would like to do is very simple apparently but I can't really get out of it.

Imagine a cell phone with a SIM and that when it is turned off I wanted to send the call to my extension on FusionPBX.

However, the fixed number registered on FusionPBX is only one and fusionpbx should understand that the call "x" is forwarded by the "y" number of my sim.

y is always the same as is my mobile number.

Is there any way to intercept this option? If I look at the provider sip logs I see this:

Code:
Accept: application/sdp, application/isup, application/xml
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, MESSAGE, NOTIFY, REGISTER, INFO, REFER, SUBSCRIBE, PUBLISH, UPDATE
History-Info: <tel:0000my-number-here000?Privacy=none>;index=1,  <tel:000the-fixed-number000;cause=302>;index=1.1


then fusionpbx could understand that the call is coming from my sim and redirect it to my extension.

In the FusionPBX logs instead there is no trace of my number but only of what is calling

You would really help anyone who can make a contribution
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
I would imagine that you would copy your existing inbound route and then in the copy add a second condition of caller_id_number=^your_sim_number$ and then have it transfer to your extension.

I would strongly advise testing this on a non production box. Inbound routes operate in the public context so any mistakes made on an inbound route have the potential to affect ALL the domains.
 
  • Like
Reactions: Fede

Fede

Member
Oct 4, 2020
35
1
6
37
Italy
Thanks @Adrian Fretwell your help is very appreciated.

But caller_id_number shows the caller and not the deviated number (call deviated from my SIM card)

I saw that when a call is deviated there are in the header this info as "History-Info" but I can't figure out if Fusion can detect in some way this number

How can I intercepted that?

Thanks!
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Ok, I think I understand, normally we would expect to see a diversion header but in your case you are just getting the History-Info header.

You can test headers in a dialplan condition using the syntax $(sip_h_History-Info) then use regex to evaluate the part of the header you are interested in. E.g.:

If your header looked like this <tel:00001234000?Privacy=none>;index=1, <tel:0005678000;cause=302>;index=1.1
then
Code:
^<tel:.*<tel:(\d+);.*$
would put the number from the second "tel:" into the capturing group.

So you would have something like:
Code:
condition   $(sip_h_History-Info)  ^<tel:.*<tel:(\d+);.*$

Hopefully you can adapt this to meet your needs.
 
  • Like
Reactions: Fede

Fede

Member
Oct 4, 2020
35
1
6
37
Italy
Really thanks for your precious response.

Unfortunately, it doesn't work because it doesn't seem to be intercepting anything.

I was able to get through that rule just by putting "$" as if to say accept everything.


But I can't find this variable $(sip_h_History-Info) in the condition list so I'm working by modifying directly from the xml, is that correct?

How could I display the contents of the variable that fusion is reading on the screen? Or have it written in the logs ..

You would have other ideas maybe Histroy-Info is not correct, what I intend to do is if I forward all calls unconditionally from my sim, the call comes in fusion with the number of who is calling and not with that of my sim (even if it passes through).

I have seen the only trace in history-info that shows my SIM number, I don't know if you have any other ideas.

How can I possibly see the entire content coming to Fusion?


Thanks again for your invaluable help
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Choose sip_h_Diversion from the list and then click in the box and edit it to be sip_h_History-Info
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
If you can give me anything else to work with, such as logs and packet captures, I may be able to work out what is happening. I can only "see" what you tell me. "done also in this way, but nothing" does not give me (or anyone else) anything to work with.

I will always help if I can.
 

Fede

Member
Oct 4, 2020
35
1
6
37
Italy
@Adrian Fretwell I really appreciated your help, thanks!

The SIP trace I got from the provider is the first message.

How can I capture the packet that are arriving to FusionPBX?
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Post a packet capture showing the INVITE to your provider and the responses coming back. The easiest tool to do this with is sngrep. Also, provide a screen shot of your inbound route. That may allow me to get an idea of what is going on.
 
Status
Not open for further replies.