This is my dialplan when extension 100 can call extension 200:
[from-internal]
exten => 200,1,Answer
same => n,Verbose(CID ${CALLERID(num)})
same => n,Wait(1)
same => n,Read(SPYNUM,extension,3,,,60)
same => n,ExecIf($[${SPYNUM}>99]?ChanSpy(PJSIP/${SPYNUM}))
same => n,Verbose(MONITOR ${SPYNUM})
same => n,Hangup
And the output in the CLI looks like this (pjsip set logger on, core set verbose 9, core set debug 9):
<--- Received SIP request (1407 bytes) from UDP:192.168.1.5:17745 --->
INVITE sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPje2c37a16b48e4530a4402f605134e568
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>
Contact: <sip:100@10.4.0.4:59393;ob>
Call-ID: 33553bc5117a4c81845b7c07613814d2
CSeq: 26943 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.26
Content-Type: application/sdp
Content-Length: 792
v=0
o=- 3790999808 3790999808 IN IP4 172.23.16.6
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4004 RTP/AVP 96 97 98 99 3 0 8 9 100 102 103 101 104 105
c=IN IP4 172.23.16.6
b=TIAS:64000
a=rtcp:4005 IN IP4 172.23.16.6
a=sendrecv
a=rtpmap:96 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:98 speex/32000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:100 AMR/8000
a=fmtp:100 octet-align=1
a=rtpmap:102 SILK/16000
a=fmtp:102 useinbandfec=0
a=rtpmap:103 SILK/8000
a=fmtp:103 useinbandfec=0
a=rtpmap:101 telephone-event/16000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/8000
a=fmtp:104 0-16
a=rtpmap:105 telephone-event/32000
a=fmtp:105 0-16
a=ssrc:245587398 cname:68d939ce32f47422
<--- Transmitting SIP response (545 bytes) to UDP:192.168.1.5:17745 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.4.0.4:59393;rport=17745;received=192.168.1.5;branch=z9hG4bKPje2c37a16b48e4530a4402f605134e568
Call-ID: 33553bc5117a4c81845b7c07613814d2
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>;tag=z9hG4bKPje2c37a16b48e4530a4402f605134e568
CSeq: 26943 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1582007353/44a17d76170265b41a2367aa31f3dbb3",opaque="67a2f94627afd30c",algorithm=md5,qop="auth"
Server: Asterisk PBX 16.7.0
Content-Length: 0
<--- Received SIP request (370 bytes) from UDP:192.168.1.5:17745 --->
ACK sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPje2c37a16b48e4530a4402f605134e568
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>;tag=z9hG4bKPje2c37a16b48e4530a4402f605134e568
Call-ID: 33553bc5117a4c81845b7c07613814d2
CSeq: 26943 ACK
Content-Length: 0
<--- Received SIP request (1700 bytes) from UDP:192.168.1.5:17745 --->
INVITE sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPj47222f5cbbcf446f9fd2657dfb1a145c
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>
Contact: <sip:100@10.4.0.4:59393;ob>
Call-ID: 33553bc5117a4c81845b7c07613814d2
CSeq: 26944 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.26
Authorization: Digest username="100", realm="asterisk", nonce="1582007353/44a17d76170265b41a2367aa31f3dbb3", uri="sip:200@192.168.1.10", response="9cb204e33906893c1ea500c9e27a9bab", algorithm=md5, cnonce="9464c08b80494683a24e36d23b7b9d8f", opaque="67a2f94627afd30c", qop=auth, nc=00000001
Content-Type: application/sdp
Content-Length: 792
v=0
o=- 3790999808 3790999808 IN IP4 172.23.16.6
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4004 RTP/AVP 96 97 98 99 3 0 8 9 100 102 103 101 104 105
c=IN IP4 172.23.16.6
b=TIAS:64000
a=rtcp:4005 IN IP4 172.23.16.6
a=sendrecv
a=rtpmap:96 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:98 speex/32000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:100 AMR/8000
a=fmtp:100 octet-align=1
a=rtpmap:102 SILK/16000
a=fmtp:102 useinbandfec=0
a=rtpmap:103 SILK/8000
a=fmtp:103 useinbandfec=0
a=rtpmap:101 telephone-event/16000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/8000
a=fmtp:104 0-16
a=rtpmap:105 telephone-event/32000
a=fmtp:105 0-16
a=ssrc:245587398 cname:68d939ce32f47422
== Setting global variable 'SIPDOMAIN' to '192.168.1.10'
<--- Transmitting SIP response (347 bytes) to UDP:192.168.1.5:17745 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.4.0.4:59393;rport=17745;received=192.168.1.5;branch=z9hG4bKPj47222f5cbbcf446f9fd2657dfb1a145c
Call-ID: 33553bc5117a4c81845b7c07613814d2
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>
CSeq: 26944 INVITE
Server: Asterisk PBX 16.7.0
Content-Length: 0
-- Executing [200@from-internal:1] Answer("PJSIP/100-0000000d", "") in new stack
> 0x7fa5d40089b0 -- Strict RTP learning after remote address set to: 172.23.16.6:4004
<--- Transmitting SIP response (898 bytes) to UDP:192.168.1.5:17745 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.4.0.4:59393;rport=17745;received=192.168.1.5;branch=z9hG4bKPj47222f5cbbcf446f9fd2657dfb1a145c
Call-ID: 33553bc5117a4c81845b7c07613814d2
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>;tag=3b761fc3-3a64-4092-bbda-5f28ce19c03f
CSeq: 26944 INVITE
Server: Asterisk PBX 16.7.0
Contact: <sip:192.168.1.10:5060>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800;refresher=uac
Require: timer
Content-Type: application/sdp
Content-Length: 235
v=0
o=- 3790999808 3790999810 IN IP4 192.168.1.10
s=Asterisk
c=IN IP4 192.168.1.10
t=0 0
m=audio 11478 RTP/AVP 0 104
a=rtpmap:0 PCMU/8000
a=rtpmap:104 telephone-event/8000
a=fmtp:104 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
<--- Received SIP request (362 bytes) from UDP:192.168.1.5:17745 --->
ACK sip:192.168.1.10:5060 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPj2ea9149825b74775871b3aab0b37019f
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>;tag=3b761fc3-3a64-4092-bbda-5f28ce19c03f
Call-ID: 33553bc5117a4c81845b7c07613814d2
CSeq: 26944 ACK
Content-Length: 0
-- Executing [200@from-internal:2] Verbose("PJSIP/100-0000000d", "CID 100") in new stack
CID 100
-- Executing [200@from-internal:3] Wait("PJSIP/100-0000000d", "1") in new stack
> 0x7fa5d40089b0 -- Strict RTP qualifying stream type: audio
> 0x7fa5d40089b0 -- Strict RTP switching source address to 192.168.1.5:34574
-- Executing [200@from-internal:4] Read("PJSIP/100-0000000d", "SPYNUM,extension,3,,,60") in new stack
-- Accepting a maximum of 3 digits.
-- <PJSIP/100-0000000d> Playing 'extension.ulaw' (language 'en')
<--- Received SIP request (392 bytes) from UDP:192.168.1.5:17745 --->
BYE sip:192.168.1.10:5060 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPje9cd10abd9fd403f8e9401001e8e1294
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>;tag=3b761fc3-3a64-4092-bbda-5f28ce19c03f
Call-ID: 33553bc5117a4c81845b7c07613814d2
CSeq: 26945 BYE
User-Agent: MicroSIP/3.19.26
Content-Length: 0
<--- Transmitting SIP response (381 bytes) to UDP:192.168.1.5:17745 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.4.0.4:59393;rport=17745;received=192.168.1.5;branch=z9hG4bKPje9cd10abd9fd403f8e9401001e8e1294
Call-ID: 33553bc5117a4c81845b7c07613814d2
From: <sip:100@192.168.1.10>;tag=e9f0e053c01440cbbf4957c57612ef70
To: <sip:200@192.168.1.10>;tag=3b761fc3-3a64-4092-bbda-5f28ce19c03f
CSeq: 26945 BYE
Server: Asterisk PBX 16.7.0
Content-Length: 0
But when I add /_100 in the dialplan:
[from-internal]
exten => 200/_100,1,Answer
same => n,Verbose(CID ${CALLERID(num)})
same => n,Wait(1)
same => n,Read(SPYNUM,extension,3,,,60)
same => n,ExecIf($[${SPYNUM}>99]?ChanSpy(PJSIP/${SPYNUM}))
same => n,Verbose(MONITOR ${SPYNUM})
same => n,Hangup
Then the output in the CLI looks like this (pjsip set logger on, core set verbose 9, core set debug 9):
<--- Received SIP request (1407 bytes) from UDP:192.168.1.5:17745 --->
INVITE sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPj9ffba957360b4d9984137f161ce46f8e
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=fac1246801c9484aa1d522ec0e05e1bb
To: <sip:200@192.168.1.10>
Contact: <sip:100@10.4.0.4:59393;ob>
Call-ID: 64f2c23550954aa98a75f6dd6a4edd10
CSeq: 28870 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.26
Content-Type: application/sdp
Content-Length: 792
v=0
o=- 3790999966 3790999966 IN IP4 172.23.16.6
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4006 RTP/AVP 96 97 98 99 3 0 8 9 100 102 103 101 104 105
c=IN IP4 172.23.16.6
b=TIAS:64000
a=rtcp:4007 IN IP4 172.23.16.6
a=sendrecv
a=rtpmap:96 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:98 speex/32000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:100 AMR/8000
a=fmtp:100 octet-align=1
a=rtpmap:102 SILK/16000
a=fmtp:102 useinbandfec=0
a=rtpmap:103 SILK/8000
a=fmtp:103 useinbandfec=0
a=rtpmap:101 telephone-event/16000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/8000
a=fmtp:104 0-16
a=rtpmap:105 telephone-event/32000
a=fmtp:105 0-16
a=ssrc:445269222 cname:4c20273939d23388
<--- Transmitting SIP response (545 bytes) to UDP:192.168.1.5:17745 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.4.0.4:59393;rport=17745;received=192.168.1.5;branch=z9hG4bKPj9ffba957360b4d9984137f161ce46f8e
Call-ID: 64f2c23550954aa98a75f6dd6a4edd10
From: <sip:100@192.168.1.10>;tag=fac1246801c9484aa1d522ec0e05e1bb
To: <sip:200@192.168.1.10>;tag=z9hG4bKPj9ffba957360b4d9984137f161ce46f8e
CSeq: 28870 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1582007511/a04168527f1bfc09eaf7525bc4936d42",opaque="5d9ad2a03ee96c0e",algorithm=md5,qop="auth"
Server: Asterisk PBX 16.7.0
Content-Length: 0
<--- Received SIP request (370 bytes) from UDP:192.168.1.5:17745 --->
ACK sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPj9ffba957360b4d9984137f161ce46f8e
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=fac1246801c9484aa1d522ec0e05e1bb
To: <sip:200@192.168.1.10>;tag=z9hG4bKPj9ffba957360b4d9984137f161ce46f8e
Call-ID: 64f2c23550954aa98a75f6dd6a4edd10
CSeq: 28870 ACK
Content-Length: 0
<--- Received SIP request (1700 bytes) from UDP:192.168.1.5:17745 --->
INVITE sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPjbd174e0cb4f4430bb7dd8c7847d52600
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=fac1246801c9484aa1d522ec0e05e1bb
To: <sip:200@192.168.1.10>
Contact: <sip:100@10.4.0.4:59393;ob>
Call-ID: 64f2c23550954aa98a75f6dd6a4edd10
CSeq: 28871 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.19.26
Authorization: Digest username="100", realm="asterisk", nonce="1582007511/a04168527f1bfc09eaf7525bc4936d42", uri="sip:200@192.168.1.10", response="5d4110068a31b90db14e6942a4346fa6", algorithm=md5, cnonce="e8c7cde391d74146b28a892e805551d0", opaque="5d9ad2a03ee96c0e", qop=auth, nc=00000001
Content-Type: application/sdp
Content-Length: 792
v=0
o=- 3790999966 3790999966 IN IP4 172.23.16.6
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4006 RTP/AVP 96 97 98 99 3 0 8 9 100 102 103 101 104 105
c=IN IP4 172.23.16.6
b=TIAS:64000
a=rtcp:4007 IN IP4 172.23.16.6
a=sendrecv
a=rtpmap:96 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:98 speex/32000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:100 AMR/8000
a=fmtp:100 octet-align=1
a=rtpmap:102 SILK/16000
a=fmtp:102 useinbandfec=0
a=rtpmap:103 SILK/8000
a=fmtp:103 useinbandfec=0
a=rtpmap:101 telephone-event/16000
a=fmtp:101 0-16
a=rtpmap:104 telephone-event/8000
a=fmtp:104 0-16
a=rtpmap:105 telephone-event/32000
a=fmtp:105 0-16
a=ssrc:445269222 cname:4c20273939d23388
<--- Transmitting SIP response (391 bytes) to UDP:192.168.1.5:17745 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 10.4.0.4:59393;rport=17745;received=192.168.1.5;branch=z9hG4bKPjbd174e0cb4f4430bb7dd8c7847d52600
Call-ID: 64f2c23550954aa98a75f6dd6a4edd10
From: <sip:100@192.168.1.10>;tag=fac1246801c9484aa1d522ec0e05e1bb
To: <sip:200@192.168.1.10>;tag=6307128f-7858-408d-af9a-a3dedeed6c82
CSeq: 28871 INVITE
Server: Asterisk PBX 16.7.0
Content-Length: 0
<--- Received SIP request (365 bytes) from UDP:192.168.1.5:17745 --->
ACK sip:200@192.168.1.10 SIP/2.0
Via: SIP/2.0/UDP 10.4.0.4:59393;rport;branch=z9hG4bKPjbd174e0cb4f4430bb7dd8c7847d52600
Max-Forwards: 70
From: <sip:100@192.168.1.10>;tag=fac1246801c9484aa1d522ec0e05e1bb
To: <sip:200@192.168.1.10>;tag=6307128f-7858-408d-af9a-a3dedeed6c82
Call-ID: 64f2c23550954aa98a75f6dd6a4edd10
CSeq: 28871 ACK
Content-Length: 0