Trunk DID is alphanumeric

Hi everyone.
I wanted to switch from pure asterisk to freePBX. I managed a lot through contexts in asterisk, but I think this is not the general idea of freePBX.
Anyway. I am using a sipgate account/trunk and I have two different numbers. The DID-format is: 123456e0 and 123456e1. As you can see I have to distinguish between the e0 and e1 in the end for the inbound routes. (The pattern _X.e0 is not working)
FreePBX is not supporting alphanumeric as I found out. How do I manage this now?

Thank you for any help.

Hello,

Are you sure that the DIDs that sipgate send to your pbx are in an alphanumeric format? can you upload a sip debug log from the provider?

Thank you,

Daniel Friedman
Trixton LTD.

Thank you for the quick reply.
I can’t access any logfiles of the provider, but I can show you the relevant lines in my asterisk log: (I think FROM DID is the relevant part)

Thanks for your help!

[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:1] Set("SIP/Sipgate-00000000", "__DIRECTION=INBOUND") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:2] Gosub("SIP/Sipgate-00000000", "sub-record-check,s,1(in,1234567e0,dontcare)") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:1] GotoIf("SIP/Sipgate-00000000", "0?initialized") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:2] Set("SIP/Sipgate-00000000", "__REC_STATUS=INITIALIZED") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:3] Set("SIP/Sipgate-00000000", "NOW=1487524492") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:4] Set("SIP/Sipgate-00000000", "__DAY=19") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:5] Set("SIP/Sipgate-00000000", "__MONTH=02") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:6] Set("SIP/Sipgate-00000000", "__YEAR=2017") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:7] Set("SIP/Sipgate-00000000", "__TIMESTR=20170219-181452") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:8] Set("SIP/Sipgate-00000000", "__FROMEXTEN=unknown") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:9] Set("SIP/Sipgate-00000000", "__MON_FMT=wav") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:10] NoOp("SIP/Sipgate-00000000", "Recordings initialized") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:11] ExecIf("SIP/Sipgate-00000000", "0?Set(ARG3=dontcare)") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:12] Set("SIP/Sipgate-00000000", "REC_POLICY_MODE_SAVE=") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:13] ExecIf("SIP/Sipgate-00000000", "0?Set(REC_STATUS=NO)") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:14] GotoIf("SIP/Sipgate-00000000", "2?checkaction") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx_builtins.c: Goto (sub-record-check,s,17)
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:17] GotoIf("SIP/Sipgate-00000000", "1?sub-record-check,in,1") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx_builtins.c: Goto (sub-record-check,in,1)
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:1] NoOp("SIP/Sipgate-00000000", "Inbound Recording Check to 1234567e0") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:2] Set("SIP/Sipgate-00000000", "FROMEXTEN=unknown") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:3] ExecIf("SIP/Sipgate-00000000", "11?Set(FROMEXTEN=08999999999)") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:4] Gosub("SIP/Sipgate-00000000", "recordcheck,1(dontcare,in,1234567e0)") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:1] NoOp("SIP/Sipgate-00000000", "Starting recording check against dontcare") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:2] Goto("SIP/Sipgate-00000000", "dontcare") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx_builtins.c: Goto (sub-record-check,recordcheck,3)
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:3] Return("SIP/Sipgate-00000000", "") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:5] Return("SIP/Sipgate-00000000", "") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:3] Set("SIP/Sipgate-00000000", "__FROM_DID=1234567e0") in new stack
[2017-02-19 18:14:52] VERBOSE[3281][C-00000000] pbx.c: Executing [[email protected]:4] Set("SIP/Sipgate-00000000", "CDR(did)=1234567e0") in new stack

Hi!

Through contexts? :wink:

I don’t understand why they do something as weird as that and I guess the best thing would be to have support for it in FreePBX but the only way I can see right now of dealing with this is to remap those weird DIDs to something entirely numerical…

ie something like 1234567e0 to 12345670 (or something more complex but still with numbers only if there is a risk of collision with a real phone number).

You would do something similar to from-pstn-e164-us which we use in North America to convert caller IDs in e164 format to something more like we are used to but for DIDs instead…

You would do a context like from-pstn-custom-sipgate which you would put in extensions_custom.conf and assign to your trunk which would do this remapping and then go to from-pstn…

None of the providers/trunk I have are like that so I never had to do something as weird as this but the idea is sound I think…

As you already have experience doing this kind of thing without using FreePBX you probably won’t have much trouble doing something like this I believe…

Good luck and have a nice day!

Nick

Hi!

I have been reading up a little on this and it seems like these are (sub)account number as well and would normally be assigned to different devices (so normally your PBX would be using only one of them and the other one would be used for an ATA, a SIP phone, etc…).

Do you currently have two trunks using these (sub) account numbers?

It looks like sipgate is apparently sending those as if they were DIDs and not sending the DIDs in the normal way…

Can you please do a

asterisk -rvvvvvvvvvvvvvvvvvvv
sip set debug on

do a call and then

sip set debug off

And post the result…

This will be extremely chatty and will contain information you most likely don’t want to post… Please modify them in a consistent way and let us know in which SIP headers (most likely) the real DID number is present in…

It might have worked this way in the past but I don’t think it is necessary to use both (sub)accounts to get calls from two different DIDs…

By the way, is there a place in sipgate’s web interface where you assign the DIDs to the (sub)accounts? Would it be possible to assign both DIDs to the same (sub)account?

Good luck and have a nice day!

Nick

Perhaps (and I don’t know, I’m just thinking while my fingers try to keep up) is that the system (and not the provider) is assigning the DIDs from his E1 line (E0) that number, and another E1 (E1, in this case) the same DID, but with the differentiator so that the contexts can handle something.

This doesn’t sound like something most SIP providers would do “out of the box”, It’s way outside my scope of experience, but it also isn’t the first time we’ve seen alphanumeric characters in a SIP extension.

As @Marbled points out, there’s nothing in the system preventing you from using one of the “early custom” contexts in the process to redefine the incoming DID into something more “general user” friendly.

@cynjut, since I wrote that I have a feeling that there must be a simpler way to deal with this…

From what I read 123456e0 and 123456e1 are most likely usernames you use for your trunks/devices (what other providers would call sub-accounts…). That number after the “e” is apparently a sequence, each new sub-account has a different one…

If these are indeed sub-accounts as what I read suggested it sounds like he might have two different trunks with that provider (one for each of these usernames) and that this provider doesn’t provide the DID in the conventional way. He possibly assigned a DID to each of these sub-accounts/trunks…

One trunk per DID is not quite scalable so it would be better if he could use only one and differentiate the DIDs another way…

I still think that what I suggested earlier would work but there is most likely an easier way to do it, the info is most likely put somewhere else and just need to be obtained and possibly parsed…

We will see once he posts his FreePBX box logs with SIP debug activated…

Have a nice day!

Nick

Hi Nick,

there is a way to assign 2 numbers to one account (like e0) so I could use it in one trunk, but only in the same account. I have a private and a business sipgate account and I’d like to use both with sipgate which brings me back to differentiating between the DID, because both accounts come in the from-trunk context. It would be really nice to differantiate in the inbound routes.

Using contexts and manipulating files takes me back to core asterisk. I’ll loose the functions like Inbound Routes etc. of freepbx won’t I?

I am wondering why freePBX is taking away asterisks build in functions like handling alphanumerics.

Here is the requested Log. I manipulated my IPs and numbers, but kept it consistent through the DOC.

[2017-02-21 20:07:53] WARNING[1225]: res_pjsip_pubsub.c:3164 pubsub_on_rx_publish_request: No registered publish handler for event presence
[2017-02-21 20:07:53] WARNING[1225]: res_pjsip_pubsub.c:640 subscription_get_handler_from_rdata: No registered subscribe handler for event presence.winfo
-- Added contact 'sip:[email protected]:5160;line=9m4vgdv3' to AOR '1002' with expiration of 3600 seconds
  == Contact 1002/sip:[email protected]:5160;line=9m4vgdv3 has been created
  == Endpoint 1002 is now Reachable
-- Contact 1002/sip:[email protected]:5160;line=9m4vgdv3 is now Reachable.  RTT: 181.683 msec

<--- SIP read from UDP:217.10.79.9:5060 --->
INVITE sip:[email protected]:5160 SIP/2.0
Record-Route: <sip:217.10.79.9;lr;ftag=as46b5ef13>
Record-Route: <sip:172.20.40.8;lr>
Record-Route: <sip:217.10.68.137;lr;ftag=as46b5ef13>
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Via: SIP/2.0/UDP 217.10.68.137;branch=z9hG4bK0ace.a97741e1ae58ee9b7c02f54fe8c81084.0
Via: SIP/2.0/UDP 217.10.77.120:5060;branch=z9hG4bK41b24263
Max-Forwards: 67
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>
Contact: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 103 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Content-Type: application/sdp
Content-Length: 403

v=0
o=root 1975977481 1975977482 IN IP4 217.10.77.120
s=sipgate VoIP GW
c=IN IP4 217.10.77.120
t=0 0
m=audio 29402 RTP/AVP 8 0 3 97 18 112 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:112 G726-32/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
<------------->
--- (18 headers 18 lines) ---
Sending to 217.10.79.9:5060 (NAT)
Sending to 217.10.79.9:5060 (NAT)
Using INVITE request as basis request - [email protected]
Found peer 'Sipgate' for '01621234567' from 217.10.79.9:5060
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
Found RTP audio format 8
Found RTP audio format 0
Found RTP audio format 3
Found RTP audio format 97
Found RTP audio format 18
Found RTP audio format 112
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format PCMU for ID 0
Found audio description format GSM for ID 3
Found audio description format iLBC for ID 97
Found audio description format G729 for ID 18
Found audio description format G726-32 for ID 112
Found audio description format telephone-event for ID 101
Capabilities: us - (ulaw), peer - audio=(ulaw|gsm|alaw|g729|ilbc|g726)/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 217.10.77.120:29402
Looking for 7280000e0 in from-trunk (domain 84.200.1.1)
sip_route_dump: route/path hop: <sip:217.10.79.9;lr;ftag=as46b5ef13>
sip_route_dump: route/path hop: <sip:172.20.40.8;lr>
sip_route_dump: route/path hop: <sip:217.10.68.137;lr;ftag=as46b5ef13>

<--- Transmitting (no NAT) to 217.10.79.9:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0;received=217.10.79.9
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Via: SIP/2.0/UDP 217.10.68.137;branch=z9hG4bK0ace.a97741e1ae58ee9b7c02f54fe8c81084.0
Via: SIP/2.0/UDP 217.10.77.120:5060;branch=z9hG4bK41b24263
Record-Route: <sip:217.10.79.9;lr;ftag=as46b5ef13>
Record-Route: <sip:172.20.40.8;lr>
Record-Route: <sip:217.10.68.137;lr;ftag=as46b5ef13>
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>
Call-ID: [email protected]
CSeq: 103 INVITE
Server: FPBX-13.0.190.20(13.14.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:[email protected]:5160>
Content-Length: 0


<------------>
-- Executing [[email protected]:1] Set("SIP/Sipgate-00000000", "__DIRECTION=INBOUND") in new stack
-- Executing [[email protected]:2] Gosub("SIP/Sipgate-00000000", "sub-record-check,s,1(in,7280000e0,dontcare)") in new stack
-- Executing [[email protected]:1] GotoIf("SIP/Sipgate-00000000", "0?initialized") in new stack
-- Executing [[email protected]:2] Set("SIP/Sipgate-00000000", "__REC_STATUS=INITIALIZED") in new stack
-- Executing [[email protected]:3] Set("SIP/Sipgate-00000000", "NOW=1487704094") in new stack
-- Executing [[email protected]:4] Set("SIP/Sipgate-00000000", "__DAY=21") in new stack
-- Executing [[email protected]:5] Set("SIP/Sipgate-00000000", "__MONTH=02") in new stack
-- Executing [[email protected]:6] Set("SIP/Sipgate-00000000", "__YEAR=2017") in new stack
-- Executing [[email protected]:7] Set("SIP/Sipgate-00000000", "__TIMESTR=20170221-200814") in new stack
-- Executing [[email protected]:8] Set("SIP/Sipgate-00000000", "__FROMEXTEN=unknown") in new stack
-- Executing [[email protected]:9] Set("SIP/Sipgate-00000000", "__MON_FMT=wav") in new stack
-- Executing [[email protected]:10] NoOp("SIP/Sipgate-00000000", "Recordings initialized") in new stack
-- Executing [[email protected]:11] ExecIf("SIP/Sipgate-00000000", "0?Set(ARG3=dontcare)") in new stack
-- Executing [[email protected]:12] Set("SIP/Sipgate-00000000", "REC_POLICY_MODE_SAVE=") in new stack
-- Executing [[email protected]:13] ExecIf("SIP/Sipgate-00000000", "0?Set(REC_STATUS=NO)") in new stack
-- Executing [[email protected]:14] GotoIf("SIP/Sipgate-00000000", "2?checkaction") in new stack
-- Goto (sub-record-check,s,17)
-- Executing [[email protected]:17] GotoIf("SIP/Sipgate-00000000", "1?sub-record-check,in,1") in new stack
-- Goto (sub-record-check,in,1)
-- Executing [[email protected]:1] NoOp("SIP/Sipgate-00000000", "Inbound Recording Check to 7280000e0") in new stack
-- Executing [[email protected]:2] Set("SIP/Sipgate-00000000", "FROMEXTEN=unknown") in new stack
-- Executing [[email protected]cord-check:3] ExecIf("SIP/Sipgate-00000000", "11?Set(FROMEXTEN=01621234567)") in new stack
-- Executing [[email protected]:4] Gosub("SIP/Sipgate-00000000", "recordcheck,1(dontcare,in,7280000e0)") in new stack
-- Executing [[email protected]:1] NoOp("SIP/Sipgate-00000000", "Starting recording check against dontcare") in new stack
-- Executing [[email protected]:2] Goto("SIP/Sipgate-00000000", "dontcare") in new stack
-- Goto (sub-record-check,recordcheck,3)
-- Executing [[email protected]:3] Return("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:5] Return("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:3] Set("SIP/Sipgate-00000000", "__FROM_DID=7280000e0") in new stack
-- Executing [[email protected]:4] Set("SIP/Sipgate-00000000", "CDR(did)=7280000e0") in new stack
-- Executing [[email protected]:5] ExecIf("SIP/Sipgate-00000000", "0 ?Set(CALLERID(name)=01621234567)") in new stack
-- Executing [[email protected]:6] Set("SIP/Sipgate-00000000", "__MOHCLASS=") in new stack
-- Executing [[email protected]:7] Set("SIP/Sipgate-00000000", "__REVERSAL_REJECT=FALSE") in new stack
-- Executing [[email protected]:8] GotoIf("SIP/Sipgate-00000000", "1?post-reverse-charge") in new stack
-- Goto (from-trunk,7280000e0,10)
-- Executing [[email protected]:10] NoOp("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:11] Set("SIP/Sipgate-00000000", "__CALLINGNAMEPRES_SV=allowed_not_screened") in new stack
-- Executing [[email protected]:12] Set("SIP/Sipgate-00000000", "__CALLINGNUMPRES_SV=allowed_not_screened") in new stack
-- Executing [[email protected]:13] Set("SIP/Sipgate-00000000", "CALLERID(name-pres)=allowed_not_screened") in new stack
-- Executing [[email protected]:14] Set("SIP/Sipgate-00000000", "CALLERID(num-pres)=allowed_not_screened") in new stack
-- Executing [[email protected]:15] NoOp("SIP/Sipgate-00000000", "CallerID Entry Point") in new stack
-- Executing [[email protected]:16] Goto("SIP/Sipgate-00000000", "ext-group,5001,1") in new stack
-- Goto (ext-group,5001,1)
-- Executing [[email protected]:1] GotoIf("SIP/Sipgate-00000000", "0?cid") in new stack
-- Executing [[email protected]:2] PlayTones("SIP/Sipgate-00000000", "ring") in new stack
-- Executing [[email protected]:3] Progress("SIP/Sipgate-00000000", "") in new stack
Audio is at 14292
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<--- Transmitting (no NAT) to 217.10.79.9:5060 --->
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0;received=217.10.79.9
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Via: SIP/2.0/UDP 217.10.68.137;branch=z9hG4bK0ace.a97741e1ae58ee9b7c02f54fe8c81084.0
Via: SIP/2.0/UDP 217.10.77.120:5060;branch=z9hG4bK41b24263
Record-Route: <sip:217.10.79.9;lr;ftag=as46b5ef13>
Record-Route: <sip:172.20.40.8;lr>
Record-Route: <sip:217.10.68.137;lr;ftag=as46b5ef13>
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>;tag=as3eddb37e
Call-ID: [email protected]
CSeq: 103 INVITE
Server: FPBX-13.0.190.20(13.14.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:[email protected]:5160>
Content-Type: application/sdp
Content-Length: 252

v=0
o=root 1519454722 1519454722 IN IP4 84.200.1.1
s=Asterisk PBX 13.14.0
c=IN IP4 84.200.1.1
t=0 0
m=audio 14292 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

<------------>
-- Executing [[email protected]:4] Macro("SIP/Sipgate-00000000", "user-callerid,") in new stack
-- Executing [[email protected]:1] Set("SIP/Sipgate-00000000", "TOUCH_MONITOR=1487704094.0") in new stack
-- Executing [[email protected]:2] Set("SIP/Sipgate-00000000", "AMPUSER=01621234567") in new stack
-- Executing [[email protected]allerid:3] GotoIf("SIP/Sipgate-00000000", "0?report") in new stack
-- Executing [[email protected]:4] ExecIf("SIP/Sipgate-00000000", "1?Set(REALCALLERIDNUM=01621234567)") in new stack
-- Executing [[email protected]:5] Set("SIP/Sipgate-00000000", "AMPUSER=") in new stack
-- Executing [[email protected]:6] GotoIf("SIP/Sipgate-00000000", "0?limit") in new stack
-- Executing [[email protected]:7] Set("SIP/Sipgate-00000000", "AMPUSERCIDNAME=") in new stack
-- Executing [[email protected]:8] GotoIf("SIP/Sipgate-00000000", "1?report") in new stack
-- Goto (macro-user-callerid,s,15)
-- Executing [[email protected]:15] GotoIf("SIP/Sipgate-00000000", "0?continue") in new stack
-- Executing [[email protected]:16] Set("SIP/Sipgate-00000000", "__TTL=64") in new stack
-- Executing [[email protected]:17] GotoIf("SIP/Sipgate-00000000", "1?continue") in new stack
-- Goto (macro-user-callerid,s,28)
-- Executing [[email protected]:28] Set("SIP/Sipgate-00000000", "CALLERID(number)=01621234567") in new stack
-- Executing [[email protected]:29] Set("SIP/Sipgate-00000000", "CALLERID(name)=01621234567") in new stack
-- Executing [[email protected]:30] GotoIf("SIP/Sipgate-00000000", "0?cnum") in new stack
-- Executing [[email protected]:31] Set("SIP/Sipgate-00000000", "CDR(cnam)=01621234567") in new stack
-- Executing [[email protected]:32] Set("SIP/Sipgate-00000000", "CDR(cnum)=01621234567") in new stack
-- Executing [[email protected]:33] Set("SIP/Sipgate-00000000", "CHANNEL(language)=en_GB") in new stack
-- Executing [[email protected]:5] Macro("SIP/Sipgate-00000000", "blkvm-setifempty,") in new stack
-- Executing [[email protected]:1] GotoIf("SIP/Sipgate-00000000", "1?init") in new stack
-- Goto (macro-blkvm-setifempty,s,4)
-- Executing [[email protected]:4] Set("SIP/Sipgate-00000000", "__BLKVM_CHANNEL=SIP/Sipgate-00000000") in new stack
-- Executing [[email protected]:5] Set("SIP/Sipgate-00000000", "SHARED(BLKVM,SIP/Sipgate-00000000)=TRUE") in new stack
-- Executing [[email protected]:6] Set("SIP/Sipgate-00000000", "GOSUB_RETVAL=TRUE") in new stack
-- Executing [[email protected]:7] MacroExit("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:6] GotoIf("SIP/Sipgate-00000000", "1?skipov") in new stack
-- Goto (ext-group,5001,9)
-- Executing [[email protected]:9] Set("SIP/Sipgate-00000000", "RRNODEST=") in new stack
-- Executing [[email protected]:10] Set("SIP/Sipgate-00000000", "__NODEST=5001") in new stack
-- Executing [[email protected]:11] GosubIf("SIP/Sipgate-00000000", "0?sub-rgsetcid,s,1()") in new stack
-- Executing [[email protected]:12] Gosub("SIP/Sipgate-00000000", "sub-record-check,s,1(rg,5001,dontcare)") in new stack
-- Executing [[email protected]:1] GotoIf("SIP/Sipgate-00000000", "11?initialized") in new stack
-- Goto (sub-record-check,s,10)
-- Executing [[email protected]:10] NoOp("SIP/Sipgate-00000000", "Recordings initialized") in new stack
-- Executing [[email protected]:11] ExecIf("SIP/Sipgate-00000000", "0?Set(ARG3=dontcare)") in new stack
-- Executing [[email protected]:12] Set("SIP/Sipgate-00000000", "REC_POLICY_MODE_SAVE=") in new stack
-- Executing [[email protected]:13] ExecIf("SIP/Sipgate-00000000", "0?Set(REC_STATUS=NO)") in new stack
-- Executing [[email protected]:14] GotoIf("SIP/Sipgate-00000000", "2?checkaction") in new stack
-- Goto (sub-record-check,s,17)
-- Executing [[email protected]:17] GotoIf("SIP/Sipgate-00000000", "0?sub-record-check,rg,1") in new stack
-- Executing [[email protected]:18] NoOp("SIP/Sipgate-00000000", "Generic rg Recording Check - 01621234567 5001") in new stack
-- Executing [[email protected]:19] Gosub("SIP/Sipgate-00000000", "recordcheck,1(dontcare,rg,5001)") in new stack
-- Executing [[email protected]:1] NoOp("SIP/Sipgate-00000000", "Starting recording check against dontcare") in new stack
-- Executing [[email protected]:2] Goto("SIP/Sipgate-00000000", "dontcare") in new stack
-- Goto (sub-record-check,recordcheck,3)
-- Executing [[email protected]k:3] Return("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:20] Return("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:13] Set("SIP/Sipgate-00000000", "RingGroupMethod=ringall") in new stack
-- Executing [[email protected]:14] Macro("SIP/Sipgate-00000000", "dial,30,Ttr,1002-1003") in new stack
-- Executing [[email protected]:1] NoOp("SIP/Sipgate-00000000", "Blind Transfer: , Attended Transfer: , User: , Alert Info: ") in new stack
-- Executing [[email protected]:2] ExecIf("SIP/Sipgate-00000000", "0?Set(ALERT_INFO=)") in new stack
-- Executing [[email protected]:3] ExecIf("SIP/Sipgate-00000000", "0?Set(ALERT_INFO=)") in new stack
-- Executing [[email protected]:4] ExecIf("SIP/Sipgate-00000000", "0?Set(ALERT_INFO=)") in new stack
-- Executing [[email protected]:5] ExecIf("SIP/Sipgate-00000000", "0?Set(CHANNEL(musicclass)=)") in new stack
-- Executing [[email protected]:6] AGI("SIP/Sipgate-00000000", "dialparties.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi
 dialparties.agi: Starting New Dialparties.agi
 dialparties.agi: Caller ID name is '01621234567' number is '01621234567'
 dialparties.agi: CW Ignore is:
 dialparties.agi: CF Ignore is:
 dialparties.agi: CW IN_USE/BUSY is: 1
   > dialparties.agi: USE_CONFIRMATION:  'FALSE'
   > dialparties.agi: RINGGROUP_INDEX:   ''
 dialparties.agi: Methodology of ring is  'ringall'
-- dialparties.agi: Added extension 1002 to extension map
-- dialparties.agi: Added extension 1003 to extension map
-- dialparties.agi: Extension 1002 cf is disabled
-- dialparties.agi: Extension 1003 cf is disabled
-- dialparties.agi: Extension 1002 do not disturb is disabled
-- dialparties.agi: Extension 1003 do not disturb is disabled
   > dialparties.agi: extnum 1002 has:  cw: 1; hascfb: 0 [] hascfu: 0 []
  == dialparties.agi: Discovered PJSIP Endpoint PJSIP/1002
-- dialparties.agi: Ended up with real PJSIP Dial string PJSIP/1002/sip:[email protected]:5160;line=9m4vgdv3
-- dialparties.agi: dbset CALLTRACE/1002 to 01621234567
   > dialparties.agi: extnum 1003 has:  cw: 1; hascfb: 0 [] hascfu: 0 []
  == dialparties.agi: Discovered PJSIP Endpoint PJSIP/1003
-- dialparties.agi: Ended up with real PJSIP Dial string PJSIP/1003/sip:[email protected]:5260;rinstance=496361c31e701c5c
-- dialparties.agi: dbset CALLTRACE/1003 to 01621234567
-- dialparties.agi: Filtered ARG3: 1002-1003
   > dialparties.agi: NODEST: 5001 adding M(auto-blkvm) to dialopts: TtrM(auto-blkvm)
   > dialparties.agi: NODEST: 5001 blkvm enabled macro already in dialopts: TtrM(auto-blkvm)
-- <SIP/Sipgate-00000000>AGI Script dialparties.agi completed, returning 0
-- Executing [[email protected]:9] NoOp("SIP/Sipgate-00000000", "Returned from dialparties with groups to dial") in new stack
-- Executing [[email protected]:10] Set("SIP/Sipgate-00000000", "LOOPCNT=2") in new stack
-- Executing [[email protected]:11] Set("SIP/Sipgate-00000000", "ITER=1") in new stack
-- Executing [[email protected]:12] Set("SIP/Sipgate-00000000", "EXTTOCALL=1002") in new stack
-- Executing [[email protected]:13] NoOp("SIP/Sipgate-00000000", "Working with 1002") in new stack
-- Executing [[email protected]:14] ExecIf("SIP/Sipgate-00000000", "0?Set(HASH(__SIPHEADERS,Alert-Info)=;volume=)") in new stack
-- Executing [[email protected]:15] ExecIf("SIP/Sipgate-00000000", "0?Set(HASH(__SIPHEADERS,Alert-Info)=;volume=)") in new stack
-- Executing [[email protected]:16] Set("SIP/Sipgate-00000000", "ITER=2") in new stack
-- Executing [[email protected]:17] GotoIf("SIP/Sipgate-00000000", "1?ndloopbegin") in new stack
-- Goto (macro-dial,s,12)
-- Executing [[email protected]:12] Set("SIP/Sipgate-00000000", "EXTTOCALL=1003") in new stack
-- Executing [[email protected]:13] NoOp("SIP/Sipgate-00000000", "Working with 1003") in new stack
-- Executing [[email protected]:14] ExecIf("SIP/Sipgate-00000000", "0?Set(HASH(__SIPHEADERS,Alert-Info)=;volume=)") in new stack
-- Executing [[email protected]:15] ExecIf("SIP/Sipgate-00000000", "0?Set(HASH(__SIPHEADERS,Alert-Info)=;volume=)") in new stack
-- Executing [[email protected]:16] Set("SIP/Sipgate-00000000", "ITER=3") in new stack
-- Executing [[email protected]:17] GotoIf("SIP/Sipgate-00000000", "0?ndloopbegin") in new stack
-- Executing [[email protected]:18] Macro("SIP/Sipgate-00000000", "dial-ringall-predial-hook,") in new stack
-- Executing [[email protected]:1] MacroExit("SIP/Sipgate-00000000", "") in new stack
-- Executing [[email protected]:19] Dial("SIP/Sipgate-00000000", "PJSIP/1002/sip:[email protected]:5160;line=9m4vgdv3&PJSIP/1003/sip:[email protected]:5260;rinstance=496361c31e701c5c,30,trM(auto-blkvm)b(func-apply-sipheaders^s^1),") in new stack
-- PJSIP/1002-00000000 Internal Gosub(func-apply-sipheaders,s,1) start
-- Executing [[email protected]:1] NoOp("PJSIP/1002-00000000", "Applying SIP Headers to channel") in new stack
-- Executing [[email protected]:2] Set("PJSIP/1002-00000000", "SIPHEADERKEYS=") in new stack
-- Executing [[email protected]:3] While("PJSIP/1002-00000000", "0") in new stack
-- Jumping to priority 7
-- Executing [[email protected]:8] Return("PJSIP/1002-00000000", "") in new stack
  == Spawn extension (from-internal, 5001, 1) exited non-zero on 'PJSIP/1002-00000000'
-- PJSIP/1002-00000000 Internal Gosub(func-apply-sipheaders,s,1) complete GOSUB_RETVAL=
-- PJSIP/1003-00000001 Internal Gosub(func-apply-sipheaders,s,1) start
-- Executing [[email protected]:1] NoOp("PJSIP/1003-00000001", "Applying SIP Headers to channel") in new stack
-- Executing [[email protected]:2] Set("PJSIP/1003-00000001", "SIPHEADERKEYS=") in new stack
-- Executing [[email protected]:3] While("PJSIP/1003-00000001", "0") in new stack
-- Jumping to priority 7
-- Executing [[email protected]:8] Return("PJSIP/1003-00000001", "") in new stack
  == Spawn extension (from-internal, 5001, 1) exited non-zero on 'PJSIP/1003-00000001'
-- PJSIP/1003-00000001 Internal Gosub(func-apply-sipheaders,s,1) complete GOSUB_RETVAL=
-- Called PJSIP/1002/sip:[email protected]:5160;line=9m4vgdv3
-- Called PJSIP/1003/sip:[email protected]:5260;rinstance=496361c31e701c5c
-- PJSIP/1003-00000001 connected line has changed. Saving it until answer for SIP/Sipgate-00000000
-- PJSIP/1002-00000000 connected line has changed. Saving it until answer for SIP/Sipgate-00000000
-- PJSIP/1003-00000001 is ringing
-- PJSIP/1002-00000000 is ringing
-- PJSIP/1002-00000000 is ringing

<--- SIP read from UDP:217.10.79.9:5060 --->
CANCEL sip:[email protected]:5160 SIP/2.0
Record-Route: <sip:217.10.79.9;lr;ftag=as46b5ef13>
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Max-Forwards: 67
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>
Call-ID: [email protected]
CSeq: 103 CANCEL
Content-Length: 0

<------------->
--- (10 headers 0 lines) ---
Sending to 217.10.79.9:5060 (no NAT)

<--- Reliably Transmitting (no NAT) to 217.10.79.9:5060 --->
SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0;received=217.10.79.9
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Via: SIP/2.0/UDP 217.10.68.137;branch=z9hG4bK0ace.a97741e1ae58ee9b7c02f54fe8c81084.0
Via: SIP/2.0/UDP 217.10.77.120:5060;branch=z9hG4bK41b24263
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>;tag=as3eddb37e
Call-ID: [email protected]
CSeq: 103 INVITE
Server: FPBX-13.0.190.20(13.14.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


<------------>

<--- Transmitting (no NAT) to 217.10.79.9:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0;received=217.10.79.9
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Record-Route: <sip:217.10.79.9;lr;ftag=as46b5ef13>
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>;tag=as3eddb37e
Call-ID: [email protected]
CSeq: 103 CANCEL
Server: FPBX-13.0.190.20(13.14.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


<------------>
  == Spawn extension (macro-dial, s, 19) exited non-zero on 'SIP/Sipgate-00000000' in macro 'dial'
  == Spawn extension (ext-group, 5001, 14) exited non-zero on 'SIP/Sipgate-00000000'
-- Executing [[email protected]:1] Macro("SIP/Sipgate-00000000", "hangupcall,") in new stack
-- Executing [[email protected]:1] GotoIf("SIP/Sipgate-00000000", "1?theend") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [[email protected]:3] ExecIf("SIP/Sipgate-00000000", "0?Set(CDR(recordingfile)=)") in new stack
-- Executing [[email protected]:4] Hangup("SIP/Sipgate-00000000", "") in new stack
  == Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'SIP/Sipgate-00000000' in macro 'hangupcall'
  == Spawn extension (ext-group, h, 1) exited non-zero on 'SIP/Sipgate-00000000'

<--- SIP read from UDP:217.10.79.9:5060 --->
ACK sip:[email protected]:5160 SIP/2.0
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK0ace.fbc71fa816fd94334ed0ae883fdf834b.0
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bK0ace.439ee4d32d4887facb60d7afa1db2057.3
Max-Forwards: 67
From: "01621234567" <sip:[email protected]>;tag=as46b5ef13
To: <sip:[email protected]>;tag=as3eddb37e
Call-ID: [email protected]
CSeq: 103 ACK
Content-Length: 0
X-hint: rr-enforced

<------------->
--- (10 headers 0 lines) ---
Really destroying SIP dialog '[email protected]' Method: ACK
[2017-02-21 20:08:17] WARNING[1225]: res_pjsip_pubsub.c:3164 pubsub_on_rx_publish_request: No registered publish handler for event presence
[2017-02-21 20:08:17] WARNING[1225]: res_pjsip_pubsub.c:640 subscription_get_handler_from_rdata: No registered subscribe handler for event presence.winfo

Hi Maximilian!

Ok… So you have a trunk for each one of them, right?

They don’t need to…

If you have two trunks each trunk can have its own context (or the same, more on that later) which later goes to the from-trunk one…

No, not if you make sure that once your custom context goes to the from-trunk/ext-did context your DID has been set appropriately…

Your sipgate business account could have a context called from-trunk-sipgate-business that sets the right business DID and then goes to from-trunk.

Similarly sipgate business account count have a context called from-trunk-sipgate-private that sets the right private DID and then goes to from-trunk.

Now, this is not scalable… If you later add other DIDs to either your business or private account that would force you to have one account per DID which is a pain…

In the log you just posted, did you see the real DID somewhere? If so, what did you replace it with?

If you did you could do a from-trunk-sipgate context that gets the DID from wherever it was, set it and then goes to the real from-trunk…

As I said, as long as you do all the necessary manipulations in your custom context (which you will put in extensions_custom.conf) you will be able to use the FreePBX inbound routes as if you had used a provider that passes the DID in the normal/usual way…

Good luck and have a nice day!

Nick

A couple of weeks ago, we were trying to help a guy in a similar spot. None of his trunks had DID information, so he had to write a context that pulled the DID info out of a different header.

Now, having said that, it should be possible to find a SIP header (or request a SIP header from the ITSP) that has the DID in it. If you can find/request that, you should be able to write a simple context that sets in inbound DID to something appropriate and have the call get routed through “from-trunk”.

Another possibility is that you can have two inbound routes. One is a default “no DID/no CID” route that grabs everything and the other reacts to something in the DID information. This would work if your “business” account actually transferred a DID to you in a relatively standard DID header, but the personal trunk didn’t.

Another possibility is to grab the E0 or E1 part and add your own “extension” number to it.

An important part of any solution is going to be changing the inbound route context so that you can split the calls into one of two (or more) destinations. A couple of years ago, I had a DAHDI connected system that would do an immediate answer. This would mean I would get no DID information at all. I set it up so that DAHDI0 and DAHDI1 went to different inbound contexts, set the DID for the incoming line, and then dropped the call into “from-pstn”.

Presumably the e0 account is one did , the e1 another, a quick remap in a custom context that goes to from-did-direct should work, there is no requirement that sip endpoints be numeric anywhere but freepbx, perhaps a feature request to correct that oversight?

There is a sip alias concept, but i think that only kicks in on internal calls, i might be wrong . . .

1 Like

Hi!

If no SIP header contains the information the easiest way to deal with this would be something like

[from-trunk-sipgate-business]
exten => _.,1,Noop(Setting DID to 123123123)
exten => _.,n,Goto(from-trunk,123123123,1)

[from-trunk-sipgate-private]
exten => _.,1,Noop(Setting DID to 456456456)
exten => _.,n,Goto(from-trunk,456456456,1)

in extensions_custom.conf

and assign these context to the appropriate trunks…

In my example 123123123 is the business DID, 456456456 is the private DID…

I don’t like this since it is not scalable but if there are no other way…

Good luck and have a nice day!

Nick

1 Like

Just to say that I’m also having issues with Sipgate’s DID and the fact it’s not just numbers. My setup works with no DID for the Sipgate inbound route…can I just leave it or am I experiencing problems I don’t even know about??
My Sipgate DID is in the format 1443361e0

OK. I’m not sure what’s going on with your system, but I’m just going to verify that the words you use mean the same things as everyone else.

You should always have an “any/any” inbound route (no DID and no CID) to catch calls that come in that don’t match your configured routes.

DID is Direct Inbound Dial number and it’s the number people call to connect to you. The Sipgate DID you are saying you were assigned doesn’t make sense - there’s no way for anyone else to dial it.

CID is Caller ID and it has two parts, the CallerID Name and CallerID Number. For Inbound Routes, the CID Number is the only part you can parse and mess with.

So, your specific question: you do not need to identify all of the inbound DIDs for your system. Your “any/any” route will catch anything that hits your system and will process it to the “default destination” for your system (typically like an IVR or voicemail).

Thanks, Dave, think I got it sorted - I changed the register string to user:pass/did from user:pass/user and Sipgate started sending me the DID instead of the username! Thank you!

Changing the Sipgate register string didn’t work for me, so I worked out a hack to get around the numeric only input field restriction.

When entering your DIDs on Inbound Routes page enter them without the alpha e.g. 1234567e0 -> 12345670. Submit them but do not click the red apply changes button yet.

ssh to your FreePBX server and update its mysql incoming table, e.g.

mysql
use asterisk;
update incoming set extension='1234567e0' where extension='12345670';
update incoming set extension='2345678e1' where extension='23456781';

etc. Confirm the tables have been updated and quit mysql:

select * from incoming;
quit

Now go back to FreePBX and click on the red apply changes button. Re-open your Inbound Routes page you will see the correct DIDs :wink:

If you ever need to edit an inbound route in the future you will have to edit the ‘e’ from the DID before submitting, then run the SQL as above.

Perhaps create a bash script to automatically do this, e.g. (all one line)

echo > didfix.sh "mysql -D asterisk -e \"update incoming set extension='1234567e0' where extension='12345670'; update incoming set extension='2345678e1' where extension='23456781'; select * from incoming;\""

Then make it executable:

chmod 755 didfix.sh

When ever you alter a route just ssh in and run

./didfix.sh

Sorry if I’m teaching grandma to suck eggs here :wink:

Faced with the same problem, I would solve it very differently: DID from provider breaks incoming routes (DID matching)

2 Likes

Lorne, thanks for that - it’s all a bit double dutch right now as I am a total newb at Asterisk/FreePBX. My method works but I’m sure yours is far superior. I will figure it out. :+1:

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