Help getting incoming Caller ID

I have not done much with asterisk in a while and afraid I am forgetting.

I have vanilla Asterisk 13.14 on a Raspberry Pi 3 that has served me well for a long time now (probably because it runs from a real SSD!)

I have an Obi 200 that is connected to a dedicated Fax Machine. My voice line connects through separate Obi202 and connects to Asterisk already, but it uses a fixed IP to authenticate to Asterisk for that reason I believe I do not have the problem with fax detailed below.

I am trying to send a message to My Kodi systems , so if I am watching TV I get the On screen message (yes comcast Xfinity copied this from Asterisk & Kodi) . SO with multiple accounts on Obi the call comes in on GV (Service Provider 1 on Obi) and dials 329 (that spells FAX) on Asterisk (Service Provider 2 on Obi). The call then does this

; Fax notification to Kodi
exten => 329,1,TrySystem(curl -v -u kodi:kodi -H "Accept: application/json" -H "Content-type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Incoming fax to: 5032225555","message":"From: ${CALLERID(name)} ${CALLERID(number)}","displaytime":15000,"image":"special://userdata/faxicon.png"},"id":0}' http://hdtvstreamersmi.local:8080/jsonrpc)
exten => 329,2,TrySystem(curl -v -u kodi:kodi -H "Accept: application/json" -H "Content-type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Incoming fax to: 5032225555","message":"From: ${CALLERID(name)} ${CALLERID(number)}","displaytime":15000,"image":"special://userdata/faxicon.png"},"id":0}' http://winmedia.local:8080/jsonrpc)
exten => 329,3,Wait(30)
exten => 329,4,Hangup()

that is send the messages to Kodi systems and do a big fat nothing other than wait 30 seconds. (the fax machine is connected directly to the Obi200 ATA , so this is all I want is this message with proper caller ID, not the extension ID.) As I recall there is some “fromuser” or “RPID” magic but do not recall the specifics.I think I used to go down this road on analog gateways.

extension (an obi200 ) registers Asterisk never shows me the incoming caller ID rather it shows me the extension name number

when I call the Fax Machine PSTN number I can see my caller ID

From: <sip:+1503MYNUMBER@10.0.0.250>;tag=SP237bfe69bfbfd4651
in the SIP invite

There is a good chance that you system is unique, so ti would very much help if you could simplify the problem, and failing that provide a brief description of what the various products do, as seen from the SIP side.

Moreover it is not clear to me what is happening. My first reading was that nothing happens at all outside Asterisk, in which case the caller ID is really irrelevant. An alternative reading is that you get the ${EXTEN} value, when you expect the caller ID, which would be strange, and the obvious thing to do is to look at he verbose logging to see exactly what curl command is being generated. Another thought is you are setting the caller ID for the endpoint from which the call is arriving and you mean endpoint name, not extension.

I’d say definitely provide logging at at least level 5, and it may be advisable to provide protocol traces and the contents of your channel driver configuration files.

I’d also suggest doing the curl from a script, so the parameters can be simple, One could easily trip up with special characters and quoting rules. Even better is probably to use AGI, and read the relevant channel variables, rather than trying to pass them on the command line.

David555 , I think your intentions are good but perhaps you do not understand or I was not clear enough.

The issue is that I am getting the number of the registered extension and not the PSTN number of the caller which DOES appear in the SIP From:… field. Everything else works fine and it actually works 100% if I use IP auth.

I have a very similar set-p that does not have this issue because it is IP auth

Likewise if I knew how to capture the “from:…” in SIP header and make it a variable , I could then just display the variable. I already do this on voice lines to display the called number on Kodi. I just do not know how to get the “from:…” header.

OR

I am sure this needs the solution i used to use on inbound calls via analog gateways that registered to Asterisk , if I just remembered what the trick was. It was exactly the same problem it only happens when registered not with IP auth.

Extensions aren’t something that can register; they are entries in extensions.conf. As such, I think you are referring to the PSTN gateway endpoint. The only way the endpoint name would appear is if you had a callerid line in your endpoint definition:

(The same applies to the, deprecated, chan_sip.)

Alternatively, your dialplan would have to have set it explicitly.

What is confusing me is that you say the gateway endpoint is registering, but also that it is sending the caller ID, not the account name, in the From header of INVITEs. To actually register, it would need send the account name in the From, but most SIP implementation would also require the account name in the From header of INVITEs, as well,

Strictly speaking, registration only applies to outgoing calls. However chan_sip (but not the current chan_pjsip) do remember the IP address and match INVITEs by that . I suppose it is just possible that chan_sip remembers the original registration From, but I’ve never heard of this, possibly because you have a strange gateway.

Although not a strict requirement, registration and authentication generally flow the same PSTN gateway that can create chargeable calls.

In any case, if you can get the PSTN gateway to send the caller ID in Remote-Party-ID or P-Asserted-Identity headers, you can enable trust for those headers, and, if present, they will be used by preference.

If the below wiki entry is correct, it looks, like chan_pjsip will ignore all incoming caller ID, by default. However, I’m not convinced it is correct in relation to From:, if there is no callerid setting for the endpoint.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Configuration_res_pjsip#Asterisk13Configuration_res_pjsip-endpoint_trust_id_inbound

Thanks david but not looking to split hairs on this thread. I really believe you do not read OP. Do you need a youtube video to show you? If so, please move on, as from the beginning you did not read OP

Yes it is VERY COMMON to have SIP extensions REGISTER as this one does. Although not technically a PSTN Gateway it probably functions much the same way. Stop splitting this hair, in fact stop replying

I am not a noob to asterisk so please cease the idiotic replies they are uselsss.

And yes I am using the “depricated chan_sip” (oooh noo). If you are you are unfamiliar with Chan_sip then stop acting like an expert offering no real solutions only rhetoric then please back off. I know there is a fix in chan_sip I have used it before.

Please kindly step aside and let someone who can read and knows chan_sip answer this

In the log below (invite) where it says "+1MYNUMBERHERE is where the callers number appears as “From…”, so yes you are dead wrong on that point. The "from Carries the originbal Caller ID which is what I need to get fromm Chan_sip to my message.



<--- SIP read from UDP:10.0.0.84:5095 --->
INVITE sip:329@10.0.0.250:5060 SIP/2.0
Call-ID: a7dfb7f17bcab27a@10.0.0.84
Content-Length: 207
CSeq: 8001 INVITE
From: <sip:+1MYNUMBERHERE@10.0.0.250>;tag=SP25f8f7ace3c741dd0
Max-Forwards: 70
To: <sip:329@10.0.0.250>
Via: SIP/2.0/UDP 10.0.0.84:5095;branch=z9hG4bK-ffd7df3a;rport
User-Agent: OBIHAI/OBi200-3.2.2.8680
Contact: <sip:601@10.0.0.84:5095>
Expires: 60
Supported: replaces
Allow: ACK,BYE,CANCEL,INFO,INVITE,NOTIFY,OPTIONS,PRACK,REFER,UPDATE
Content-Type: application/sdp

v=0
o=- 3272028 1 IN IP4 10.0.0.84
s=-
c=IN IP4 10.0.0.84
t=0 0
m=audio 14814 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv
a=ptime:30
a=xg726bitorder:big-endian

<------------->
--- (14 headers 11 lines) ---
Sending to 10.0.0.84:5095 (no NAT)
Sending to 10.0.0.84:5095 (no NAT)
Using INVITE request as basis request - a7dfb7f17bcab27a@10.0.0.84
Found peer '601' for '+1MYNUMBERHERE' from 10.0.0.84:5095

<--- Reliably Transmitting (no NAT) to 10.0.0.84:5095 --->
SIP/2.0 401 Unauthorized
v: SIP/2.0/UDP 10.0.0.84:5095;branch=z9hG4bK-ffd7df3a;received=10.0.0.84;rport=5095
f: <sip:+1MYNUMBERHERE@10.0.0.250>;tag=SP25f8f7ace3c741dd0
t: <sip:329@10.0.0.250>;tag=as3e9e9830
i: a7dfb7f17bcab27a@10.0.0.84
CSeq: 8001 INVITE
Server: NoneOfYourBusiness
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
k: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="23d387cd"
l: 0


<------------>
Scheduling destruction of SIP dialog 'a7dfb7f17bcab27a@10.0.0.84' in 6400 ms (Method: INVITE)

<--- SIP read from UDP:10.0.0.84:5095 --->
ACK sip:329@10.0.0.250:5060 SIP/2.0
Call-ID: a7dfb7f17bcab27a@10.0.0.84
Content-Length: 0
CSeq: 8001 ACK
From: <sip:+1MYNUMBERHERE@10.0.0.250>;tag=SP25f8f7ace3c741dd0
Max-Forwards: 70
To: <sip:329@10.0.0.250>;tag=as3e9e9830
Via: SIP/2.0/UDP 10.0.0.84:5095;branch=z9hG4bK-ffd7df3a;rport
User-Agent: OBIHAI/OBi200-3.2.2.8680


<------------->
--- (9 headers 0 lines) ---

<--- SIP read from UDP:10.0.0.84:5095 --->
INVITE sip:329@10.0.0.250:5060 SIP/2.0
Call-ID: a7dfb7f17bcab27a@10.0.0.84
Content-Length: 207
CSeq: 8002 INVITE
From: <sip:+1MYNUMBERHERE@10.0.0.250>;tag=SP25f8f7ace3c741dd0
Max-Forwards: 70
To: <sip:329@10.0.0.250>
Via: SIP/2.0/UDP 10.0.0.84:5095;branch=z9hG4bK-42dbc001;rport
Authorization: Digest algorithm=MD5,nonce="23d387cd",realm="asterisk",response="43495f24e93f558401b89c3d42737320",uri="sip:329@10.0.0.250:5060",username="601"
User-Agent: OBIHAI/OBi200-3.2.2.8680
Contact: <sip:601@10.0.0.84:5095>
Expires: 60
Supported: replaces
Allow: ACK,BYE,CANCEL,INFO,INVITE,NOTIFY,OPTIONS,PRACK,REFER,UPDATE
Content-Type: application/sdp

v=0
o=- 3272028 1 IN IP4 10.0.0.84
s=-
c=IN IP4 10.0.0.84
t=0 0
m=audio 14814 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv
a=ptime:30
a=xg726bitorder:big-endian

<------------->
--- (15 headers 11 lines) ---
Sending to 10.0.0.84:5095 (no NAT)
Using INVITE request as basis request - a7dfb7f17bcab27a@10.0.0.84
Found peer '601' for '601' from 10.0.0.84:5095
  == Using SIP RTP CoS mark 5
Found RTP audio format 0
Found RTP audio format 101
Found audio description format PCMU for ID 0
Found audio description format telephone-event for ID 101
Capabilities: us - (ulaw|alaw), peer - audio=(ulaw)/video=(nothing)/text=(nothing), combined - (ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
       > 0x73f1cde8 -- Strict RTP learning after remote address set to: 10.0.0.84:14814
Peer audio RTP is at port 10.0.0.84:14814
Looking for 329 in from-internal (domain 10.0.0.250)
sip_route_dump: route/path hop: <sip:601@10.0.0.84:5095>

<--- Transmitting (no NAT) to 10.0.0.84:5095 --->
SIP/2.0 100 Trying
v: SIP/2.0/UDP 10.0.0.84:5095;branch=z9hG4bK-42dbc001;received=10.0.0.84;rport=5095
f: <sip:+1MYNUMBERHERE@10.0.0.250>;tag=SP25f8f7ace3c741dd0
t: <sip:329@10.0.0.250>
i: a7dfb7f17bcab27a@10.0.0.84
CSeq: 8002 INVITE
Server: NoneOfYourBusiness
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
k: replaces, timer
m: <sip:329@10.0.0.250:5060>
l: 0


<------------>
    -- Executing [329@from-internal:1] TrySystem("SIP/601-00000088", "curl -v -u kodi:kodi -H "Accept: application/json" -H "Content-type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Incoming fax to: FAXNUMBERHERE","message":"From: Fax 601","displaytime":15000,"image":"special://userdata/faxicon.png"},"id":0}' http://hdtvstreamersmi.local:8080/jsonrpc") in new stack
    -- Executing [329@from-internal:2] TrySystem("SIP/601-00000088", "curl -v -u kodi:kodi -H "Accept: application/json" -H "Content-type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Incoming fax to: FAXNUMBERHERE","message":"From: Fax 601","displaytime":15000,"image":"special://userdata/faxicon.png"},"id":0}' http://winmedia.local:8080/jsonrpc") in new stack
    -- Executing [329@from-internal:3] Wait("SIP/601-00000088", "30") in new stack


Update

I am now also setting P- Preferred identity and can see it in invite:


P-Preferred-Identity: <sip:+1MYNUMBER@10.0.0.250>

Seems I can not get assterisk to use it as caller ID

Do you only care about getting the calling number for your system commands or actually having the right CALLERID(num) ?

Any reason you can’t use the SIP_HEADER function and CUT to manually extract what you want from the From header, and then pass that into the commands?

e.g. Asterisk 16 Function_SIP_HEADER - Asterisk Project - Asterisk Project Wiki

Set(from=${SIP_HEADER(From,1)})
Set(from=${CUT(from,@,1)})
Set(from=${FILTER(0-9,${from})})

Maybe I’m not understanding something, but if you’re getting information in the headers that you want, you should be able at least to manually extract it for your commands.

That looks right and will test. I think you understand. I could Also use the P-Preferred Identity with that as it cuts out everything but the number. Great Will test ASAP.

Beautiful! It works
this

exten => 329,1, Set(from=${SIP_HEADER(From,1)})
exten => 329,2,Set(from=${CUT(from,@,1)})
exten => 329,3,Set(from=${FILTER(0-9,${from})})
exten => 329,4,NoOp(${from})

Gives me this

    -- Executing [329@from-internal:1] Set("SIP/601-0000002c", "from=<sip:+15034890000@10.0.0.250>;tag=SP27fcd34e85d9d394c") in new stack
    -- Executing [329@from-internal:2] Set("SIP/601-0000002c", "from=<sip:+15034890000") in new stack
    -- Executing [329@from-internal:3] Set("SIP/601-0000002c", "from=15034890000") in new stack
    -- Executing [329@from-internal:4] NoOp("SIP/601-0000002c", "15034890000") in new stack

Thanks! This is RESOLVED I appreciate the solution!

I want to add for anyone else looking for this solution that if your callers number appears in P-Preferred-Identity or P-Asserted-Identity, I think you can also use

${SIP_HEADER(P-Preferred-Identity)}

or

${SIP_HEADER(P-Asserted-Identity)}

in place of

${SIP_HEADER(From,1)}

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