Thanks for that Lorne,
Very useful:
My sanitised output is:
pbxa*CLI> sip set debug peer PLIVOTRUNK000
SIP Debugging Enabled for IP: XX.X.XXX.123
Reliably Transmitting (NAT) to XX.X.XXX.123:5060:
OPTIONS sip:phone.plivo.com SIP/2.0
Via: SIP/2.0/UDP 51.254.204.89:5160;branch=z9hG4bK33014126;rport
Max-Forwards: 70
From: "Unknown" <sip:[email protected]:5160>;tag=as02256083
To: <sip:phone.plivo.com>
Contact: <sip:[email protected]:5160>
Call-ID: [email protected]:5160
CSeq: 102 OPTIONS
User-Agent: FPBX-13.0.190.9(13.13.1)
Date: Fri, 06 Jan 2017 22:35:43 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0
---
<--- SIP read from UDP:XX.X.XXX.123:5060 --->
SIP/2.0 484 Address Incomplete
Via: SIP/2.0/UDP XX.X.XXX..89:5160;branch=z9hG4bK33014126;rport=5160;received=XX.X.XXX..89
From: "Unknown" <sip:[email protected]:5160>;tag=as02256083
To: <sip:phone.plivo.com>;tag=474ffd7c21aee331a23ec34c5cbcdf9d.1ab7
Call-ID: [email protected]:5160
CSeq: 102 OPTIONS
Server: kamailio (4.3.6 (x86_64/linux))
Content-Length: 0
<------------->
--- (8 headers 0 lines) ---
Really destroying SIP dialog '[email protected]:5160' Method: OPTIONS
<--- SIP read from UDP:XX.X.XXX.123:5060 --->
INVITE sip:[email protected]:5160;transport=UDP SIP/2.0
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0
Via: SIP/2.0/UDP 52.59.63.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Max-Forwards: 40
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Contact: <sip:[email protected]:5080>
User-Agent: Plivo
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, refer
Privacy: none
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 300
P-Asserted-Identity: "+447877000000" <sip:[email protected]>
P-hint: outbound
v=0
o=FreeSWITCH 1483719044 1483719045 IN IP4 XX.X.XXX.228
s=FreeSWITCH
c=IN IP4 XX.X.XXX.228
t=0 0
m=audio 23118 RTP/AVP 0 8 102 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:102 SPEEX/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
<------------->
--- (20 headers 13 lines) ---
Sending to XX.X.XXX.123:5060 (NAT)
Sending to XX.X.XXX.123:5060 (NAT)
Using INVITE request as basis request - 5d4717db-81da-4321-b9cf-24d2d215be6b
Found peer 'PLIVOTRUNK000' for '+447877000000' from XX.X.XXX.123:5060
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
Found RTP audio format 0
Found RTP audio format 8
Found RTP audio format 102
Found RTP audio format 101
Found audio description format PCMU for ID 0
Found audio description format PCMA for ID 8
Found audio description format SPEEX for ID 102
Found audio description format telephone-event for ID 101
Capabilities: us - (gsm|ulaw|g722), peer - audio=(ulaw|alaw|speex)/video=(nothing)/text=(nothing), combined - (ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port XX.X.XXX.228:23118
Looking for s in custom-get-did-from-plivo (domain XX.X.XXX..89)
sip_route_dump: route/path hop: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
<--- Transmitting (NAT) to XX.X.XXX.123:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0;received=XX.X.XXX.123;rport=5060
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Server: FPBX-13.0.190.9(13.13.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: <sip:[email protected]:5160>
Content-Length: 0
<------------>
-- Executing [s@custom-get-did-from-plivo:1] NoOp("SIP/PLIVOTRUNK000-00000095", "Fixing DID using information from PLIVO TO header") in new stack
-- Executing [s@custom-get-did-from-plivo:2] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=<sip:[email protected];transport=udp>") in new stack
-- Executing [s@custom-get-did-from-plivo:3] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=<sip:PLIVOTRUNK000") in new stack
-- Executing [s@custom-get-did-from-plivo:4] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=PLIVOTRUNK000") in new stack
-- Executing [s@custom-get-did-from-plivo:5] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=DDI I WANT TO ASSIGN") in new stack
Audio is at 14882
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
<--- Reliably Transmitting (NAT) to XX.X.XXX.123:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0;received=XX.X.XXX.123;rport=5060
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>;tag=as6cebb232
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Server: FPBX-13.0.190.9(13.13.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: <sip:[email protected]:5160>
Content-Type: application/sdp
Require: timer
Content-Length: 252
v=0
o=root 611487133 611487133 IN IP4 XX.X.XXX..89
s=Asterisk PBX 13.13.1
c=IN IP4 XX.X.XXX..89
t=0 0
m=audio 14882 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
<------------>
Retransmitting #1 (NAT) to XX.X.XXX.123:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0;received=XX.X.XXX.123;rport=5060
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>;tag=as6cebb232
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Server: FPBX-13.0.190.9(13.13.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: <sip:[email protected]:5160>
Content-Type: application/sdp
Require: timer
Content-Length: 252
v=0
o=root 611487133 611487133 IN IP4 XX.X.XXX..89
s=Asterisk PBX 13.13.1
c=IN IP4 XX.X.XXX..89
t=0 0
m=audio 14882 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
---
<--- SIP read from UDP:XX.X.XXX.123:5060 --->
ACK sip:[email protected]:5160 SIP/2.0
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF>
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.8a361f586d9cdd51c66a3c87e3e48b56.0
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKgjZtr21HU7F1r
Max-Forwards: 69
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>;tag=as6cebb232
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 ACK
Contact: <sip:[email protected]:5080>
Content-Length: 0
<------------->
As you can see, the To: in the header is my Sip uri from my plivo endpoint.
Plivo just simply does not pass the DID when sending a call to my FreePBX.
However i have managed to get a single number to route so far.:
I created a custom context to pull the Siptrunk URI name into the DDI and then replace it with the DID i want freepbx to see.
It seems i will need to do Seperate trunks for each DID and seperate contexts!!! man this is so rubbish!