[Home]

Summary:ASTERISK-28767: chan_pjsip: Caller ID not used when checking for extension, callerid supplement executed too late
Reporter:Oleg (olegsenin)Labels:patch
Date Opened:2020-03-05 02:09:49.000-0600Date Closed:2022-12-20 09:55:19.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Channels/chan_pjsip Resources/res_pjsip_caller_id
Versions:16.0.1 16.8.0 Frequency of
Occurrence
Related
Issues:
is duplicated byASTERISK-29524 The patterns "*" and "#" do not work when calling via a PJSIP trunk
Environment:Attachments:( 0) 3333.jpg
( 1) ASTERISK-28767.diff
Description:{noformat}
[DLPN_DialPlan1]
exten => _8[89]XXXXXXXXX/_2000,1,Answer()
same => n,Verbose(111111111111111111 CID ${CALLERID(num)})
same => n,Dumpchan()
same => n,Wait(1)
same => n,Hangup
exten => _8[89]XXXXXXXXX/2000,1,Answer()
same => n,Verbose(44444444444 CID ${CALLERID(num)})
same => n,Dumpchan()
same => n,Wait(1)
same => n,Hangup
exten => _8[89]XXXXXXXXX,1,Answer()
same => n,Verbose(!!!!!!!!!!!! CID ${CALLERID(num)})
same => n,Dumpchan()
same => n,Wait(1)
same => n,Hangup
{noformat}
Asterisk:
{noformat}
Setting global variable 'SIPDOMAIN' to '10.40.8.162'
   -- Executing [89051333333@DLPN_DialPlan1:1] Answer("PJSIP/2000-00000004", "") in new stack
      > 0x7f262405f0d0 -- Strict RTP learning after remote address set to: 10.40.4.223:50836
      > 0x7f262405f0d0 -- Strict RTP switching to RTP target address 10.40.4.223:50836 as source
   -- Executing [89051333333@DLPN_DialPlan1:2] Verbose("PJSIP/2000-00000004", "44444444444 CID 2000") in new stack
44444444444 CID 2000
   -- Executing [89051333333@DLPN_DialPlan1:3] DumpChan("PJSIP/2000-00000004", "") in new stack
{noformat}
Dumping Info For Channel: PJSIP/2000-00000004:
{noformat}
================================================================================
Info:
Name=               PJSIP/2000-00000004
Type=               PJSIP
UniqueID=           1583394430.6
LinkedID=           1583394430.6
CallerIDNum=        2000
CallerIDName=       Ananas
ConnectedLineIDNum= (N/A)
ConnectedLineIDName=(N/A)
DNIDDigits=         89051333333
RDNIS=              (N/A)
Parkinglot=        
Language=           en
State=              Up (6)
Rings=              1
NativeFormat=       (alaw)
WriteFormat=        alaw
ReadFormat=         alaw
RawWriteFormat=     alaw
RawReadFormat=      alaw
WriteTranscode=     No
ReadTranscode=      No
1stFileDescriptor=  -1
Framesin=           15
Framesout=          0
TimetoHangup=       0
ElapsedTime=        0h0m0s
BridgeID=           (Not bridged)
Context=            DLPN_DialPlan1
Extension=          89051333333
Priority=           3
CallGroup=          
PickupGroup=        
Application=        DumpChan
Data=               (Empty)
Blocking_in=        (Not Blocking)
{noformat}
Variables:
{noformat}
================================================================================
   -- Executing [89051333333@DLPN_DialPlan1:4] Wait("PJSIP/2000-00000004", "1") in new stack
   -- Executing [89051333333@DLPN_DialPlan1:5] Hangup("PJSIP/2000-00000004", "") in new stack
 == Spawn extension (DLPN_DialPlan1, 89051333333, 5) exited non-zero on 'PJSIP/2000-00000004'[/spoiler]
{noformat}
Delete the bottom lines:
{noformat}
[DLPN_DialPlan1]
exten => _8[89]XXXXXXXXX/_2000,1,Answer()
same => n,Verbose(111111111111111111 CID ${CALLERID(num)})
same => n,Dumpchan()
same => n,Wait(1)
same => n,Hangup
exten => _8[89]XXXXXXXXX/2000,1,Answer()
same => n,Verbose(44444444444 CID ${CALLERID(num)})
same => n,Dumpchan()
same => n,Wait(1)
same => n,Hangup
; exten => _8[89]XXXXXXXXX,1,Answer()
; same => n,Verbose(!!!!!!!!!!!! CID ${CALLERID(num)})
; same => n,Dumpchan()
; same => n,Wait(1)
; same => n,Hangup
{noformat}
Asterisk:
{noformat}
[Mar  5 10:53:05] NOTICE[2216]: res_pjsip_session.c:3078 new_invite: Call from '2000' (UDP:10.40.4.223:54005) to extension '89051333333' rejected because extension not found in context 'DLPN_DialPlan1'.
{noformat}
pjsip_wizard.conf
{noformat}
[user_defaults](!)
type = wizard
transport = ipv4
accepts_registrations = yes
sends_registrations = no
accepts_auth = yes
sends_auth = no
has_hint = yes
hint_context = DLPN_DialPlan1
hint_application = Gosub(stdexten,${EXTEN},1(${HINT}))
endpoint/context = DLPN_DialPlan1
endpoint/allow_subscribe = yes
endpoint/allow = !all,alaw
endpoint/direct_media = yes
endpoint/force_rport = yes
endpoint/disable_direct_media_on_nat = yes
endpoint/direct_media_method = invite
endpoint/ice_support = yes
endpoint/moh_suggest = default
endpoint/send_rpid = yes
endpoint/rewrite_contact = yes
endpoint/send_pai = yes
endpoint/allow_transfer = yes
endpoint/trust_id_inbound = yes
endpoint/device_state_busy_at = 1
endpoint/trust_id_outbound = yes
endpoint/send_diversion = yes
aor/qualify_frequency = 30
aor/authenticate_qualify = no
aor/max_contacts = 1
aor/remove_existing = yes
aor/minimum_expiration = 30
aor/support_path = yes

[bob](user_defaults)
hint_exten = 1000
inbound_auth/username = bob
inbound_auth/password = bobspassword

[alice](user_defaults)
hint_exten = 1001
endpoint/callerid = Alice <1001>
inbound_auth/username = alice
inbound_auth/password = alicespassword

[2000](user_defaults)
hint_exten = 2000
endpoint/callerid = Ananas <2000>
inbound_auth/username = 2000
inbound_auth/password = Ananas2000
{noformat}
With the sip driver, the bottom line was not required.
Comments:By: Asterisk Team (asteriskteam) 2020-03-05 02:09:49.828-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Joshua C. Colp (jcolp) 2020-03-05 07:36:13.313-0600

Please try this attached patch and see if it resolves the issue.

By: Oleg (olegsenin) 2020-03-10 01:56:49.012-0500

Does not work.

aster16*CLI> dialplan show DLPN_DialPlan1
[ Context 'DLPN_DialPlan1' created by 'res_pjsip_config_wizard' ]
 '1000' =>         hint: PJSIP/bob                               [res_pjsip_config_wizard]
                   1. Gosub(stdexten,${EXTEN},1(${HINT}))        [res_pjsip_config_wizard]
 '1001' =>         hint: PJSIP/alice                             [res_pjsip_config_wizard]
                   1. Gosub(stdexten,${EXTEN},1(${HINT}))        [res_pjsip_config_wizard]
 '2000' =>         hint: PJSIP/2000                              [res_pjsip_config_wizard]
                   1. Gosub(stdexten,${EXTEN},1(${HINT}))        [res_pjsip_config_wizard]
 '_8[89]XXXXXXXXX' (CID match '2000') =>  1. Answer()                                   [extensions.conf:7]
                   2. Verbose(44444444444 CID ${CALLERID(num)})  [extensions.conf:8]
                   3. Dumpchan()                                 [extensions.conf:9]
                   4. Wait(1)                                    [extensions.conf:10]
                   5. Hangup()                                   [extensions.conf:11]
 '_8[89]XXXXXXXXX' (CID match '_2000') =>  1. Answer()                                   [extensions.conf:2]
                   2. Verbose(111111111111111111 CID ${CALLERID(num)}) [extensions.conf:3]
                   3. Dumpchan()                                 [extensions.conf:4]
                   4. Wait(1)                                    [extensions.conf:5]
                   5. Hangup()                                   [extensions.conf:6]
 '_8[89]XXXXXXXXX' => 1. Answer()                                   [extensions.conf:12]
                   2. Verbose(!!!!!!!!!!!! CID ${CALLERID(num)}) [extensions.conf:13]
                   3. Dumpchan()                                 [extensions.conf:14]
                   4. Wait(1)                                    [extensions.conf:15]
                   5. Hangup()                                   [extensions.conf:16]

-= 6 extensions (21 priorities) in 1 context. =-
 == Setting global variable 'SIPDOMAIN' to '10.40.8.162'
   -- Executing [89051333333@DLPN_DialPlan1:1] Answer("PJSIP/2000-00000000", "") in new stack
      > 0x7f32240197e0 -- Strict RTP learning after remote address set to: 10.40.4.223:51548
      > 0x7f32240197e0 -- Strict RTP switching to RTP target address 10.40.4.223:51548 as source
   -- Executing [89051333333@DLPN_DialPlan1:2] Verbose("PJSIP/2000-00000000", "44444444444 CID 2000") in new stack
44444444444 CID 2000
   -- Executing [89051333333@DLPN_DialPlan1:3] DumpChan("PJSIP/2000-00000000", "") in new stack

Dumping Info For Channel: PJSIP/2000-00000000:
================================================================================
Info:
Name=               PJSIP/2000-00000000
Type=               PJSIP
UniqueID=           1583823500.0
LinkedID=           1583823500.0
CallerIDNum=        2000
CallerIDName=       Ananas
ConnectedLineIDNum= (N/A)
ConnectedLineIDName=(N/A)
DNIDDigits=         89051333333
RDNIS=              (N/A)
Parkinglot=        
Language=           en
State=              Up (6)
Rings=              1
NativeFormat=       (alaw)
WriteFormat=        alaw
ReadFormat=         alaw
RawWriteFormat=     alaw
RawReadFormat=      alaw
WriteTranscode=     No
ReadTranscode=      No
1stFileDescriptor=  -1
Framesin=           14
Framesout=          0
TimetoHangup=       0
ElapsedTime=        0h0m0s
BridgeID=           (Not bridged)
Context=            DLPN_DialPlan1
Extension=          89051333333
Priority=           3
CallGroup=          
PickupGroup=        
Application=        DumpChan
Data=               (Empty)
Blocking_in=        (Not Blocking)

Variables:
================================================================================
   -- Executing [89051333333@DLPN_DialPlan1:4] Wait("PJSIP/2000-00000000", "1") in new stack
   -- Executing [89051333333@DLPN_DialPlan1:5] Hangup("PJSIP/2000-00000000", "") in new stack
 == Spawn extension (DLPN_DialPlan1, 89051333333, 5) exited non-zero on 'PJSIP/2000-00000000'

aster16*CLI> dialplan show DLPN_DialPlan1
[ Context 'DLPN_DialPlan1' created by 'res_pjsip_config_wizard' ]
 '1000' =>         hint: PJSIP/bob                               [res_pjsip_config_wizard]
                   1. Gosub(stdexten,${EXTEN},1(${HINT}))        [res_pjsip_config_wizard]
 '1001' =>         hint: PJSIP/alice                             [res_pjsip_config_wizard]
                   1. Gosub(stdexten,${EXTEN},1(${HINT}))        [res_pjsip_config_wizard]
 '2000' =>         hint: PJSIP/2000                              [res_pjsip_config_wizard]
                   1. Gosub(stdexten,${EXTEN},1(${HINT}))        [res_pjsip_config_wizard]
 '_8[89]XXXXXXXXX' (CID match '2000') =>  1. Answer()                                   [extensions.conf:7]
                   2. Verbose(44444444444 CID ${CALLERID(num)})  [extensions.conf:8]
                   3. Dumpchan()                                 [extensions.conf:9]
                   4. Wait(1)                                    [extensions.conf:10]
                   5. Hangup()                                   [extensions.conf:11]
 '_8[89]XXXXXXXXX' (CID match '_2000') =>  1. Answer()                                   [extensions.conf:2]
                   2. Verbose(111111111111111111 CID ${CALLERID(num)}) [extensions.conf:3]
                   3. Dumpchan()                                 [extensions.conf:4]
                   4. Wait(1)                                    [extensions.conf:5]
                   5. Hangup()                                   [extensions.conf:6]

-= 5 extensions (16 priorities) in 1 context. =-
[Mar 10 09:59:19] NOTICE[49480]: res_pjsip_session.c:3078 new_invite: Call from '2000' (UDP:10.40.4.223:63076) to extension '89051333333' rejected because extension not found in context 'DLPN_DialPlan1'.
aster16*CLI>


By: Olaf Winkler (abw1oim) 2020-04-08 07:30:07.346-0500

Hi Joshua,

the problem with You patch is, that both - session->id.number.valid and session->id.number.str - are still not initialized when teh call goes into get_destination.
If this is intended it would be necessary here to fetch the callerid for the CID-Matching from the respective From-Header (which should be avbailable in rdata) before calling ast_exists_extension.

Can be verified with just printing it out before comparison:

ast_log(LOG_ERROR, "Got callerid : %s .\n", session->id.number.str);
ast_log(LOG_ERROR, "Got callerid-valied : %d .\n", session->id.number.valid);

Gets You <null> and 0 and thus the CID-Match will not be successfull.

Unfortunately I'm not the "PJSIP-Expert" and don't have the time to dig through all APIs. maybe You can have a look at this and suggest a way for getting the Callerid-Info here (if we don't have an non-intended issue of initializing these values too late in teh process).

KR
Olaf Winkler

By: Joshua C. Colp (jcolp) 2020-04-08 07:34:05.378-0500

Yes, I saw that after further investigation. I'm not currently working on this or investigating further.

By: Max Arturo (maxarturo) 2021-07-19 12:59:06.243-0500

I beg your pardon, do I understand correctly that the problem has been known for 1.5 years, but during this time they have not been involved in its solution and currently no work in this direction is being carried out?

By: Joshua C. Colp (jcolp) 2021-07-19 13:03:03.037-0500

There is no individual that I am aware of working on this issue currently.

By: Max Arturo (maxarturo) 2021-07-19 13:04:52.909-0500

I understood you. And also, please clarify, is the problem relevant only for the 16th version, or is it saved in the 17th and 18th versions?

By: Joshua C. Colp (jcolp) 2021-07-19 13:06:08.868-0500

The issue has not been closed, so it is relevant to current versions as well. We generally do not go back and update every issue when new versions are released.

By: Max Arturo (maxarturo) 2021-07-19 13:10:08.126-0500

Understood you, thanks for the info
It's a pity, of course - apparently, we will have to postpone plans to switch to using the PJSIP driver for the *distant* future ...

By: Friendly Automation (friendly-automation) 2022-12-20 09:55:20.430-0600

Change 19730 merged by Friendly Automation:
res_pjsip_session: Use Caller ID for extension matching.

[https://gerrit.asterisk.org/c/asterisk/+/19730|https://gerrit.asterisk.org/c/asterisk/+/19730]

By: Friendly Automation (friendly-automation) 2022-12-20 09:55:24.141-0600

Change 19604 merged by Friendly Automation:
res_pjsip_session: Use Caller ID for extension matching.

[https://gerrit.asterisk.org/c/asterisk/+/19604|https://gerrit.asterisk.org/c/asterisk/+/19604]

By: Friendly Automation (friendly-automation) 2022-12-20 14:13:22.460-0600

Change 19731 merged by George Joseph:
res_pjsip_session: Use Caller ID for extension matching.

[https://gerrit.asterisk.org/c/asterisk/+/19731|https://gerrit.asterisk.org/c/asterisk/+/19731]