Adding custom headers per pbx on inbound call (Carriers -> DSIPRouter -> PBX)

187 views
Skip to first unread message

Serge S

unread,
Jan 9, 2021, 4:08:40 PM1/9/21
to dSIPRouter
Hey all !,

I'm trying to set up DSIPRouter in a basic scenario.
Carrier <-> DSIPRouter <-> PBX01, PBX02, ...
So far it's working like a charm.

But now, I'm trying to use a multi-tenant asterisk PBX. To use the same provider (My DSIPRouter ) for multiple tenants, I need DSIPRouter to send something that allow me to match the configured trunk on the Asterisk PBX for inbound call.
 
For example, we could add match_header X-Origin-Trunk: <Endpoint_Groups_ID> in the identify section of each trunks.

I've found where to add some code append_hf(.....) in kamailio_dsiprouter.cfg to fit my purpose. Put I don't know what var or function I could use to find (and print) what Endpoint Group has been used .

Anyone?

Thank you for your help

Best regards

Serge

richard

unread,
Jan 11, 2021, 10:51:02 AM1/11/21
to dSIPRouter
Hello Serge,
You can add the logic for it after this line.
https://github.com/dOpensource/dsiprouter/blob/master/kamailio/kamailio_dsiprouter.cfg#L894

You first need to look up the group id by using the information provided by dr_routing which can be done with the logic below:
if ($avp(dr_attrs) != $null) {
$avp(dst_gwid) = $(avp(dr_attrs){s.select,0,,});
$avp(dst_gwtype) = $(avp(dr_attrs){s.select,1,,});
$avp(dst_gwgroupid) = $sht(gw2gwgroup=>$avp(dst_gwid));
}  

Then you need to add a header that contains it. 



Serge S

unread,
Jan 11, 2021, 7:02:35 PM1/11/21
to dSIPRouter
Dear Richard,

Thank you so much!!!

I had tried this before ! but it had failed ! Why? because instead putting it on line 894, I had chosen to put it on line 877 just before condition if (do_routing($avp(dr_groupid))) {...

And it was always returning "Null".

You're a star!!! Thank you so much. It works exactly as expected !
Now I can manage different trunks from my single DSIPRouter to my multi-tenant PBX.
PERFECT!!!

keep on this excellent job you're doing on DSIPRouter!

Thank you!

Best regards

Chico Perez

unread,
Jan 12, 2021, 1:03:36 PM1/12/21
to dSIPRouter
Hello Sergio,
   Can you please assist as I am struggling to do the same? 

Serge S

unread,
Jan 13, 2021, 4:05:55 AM1/13/21
to dSIPRouter
Hi Chico,

Tell me how I could help?

Chico Perez

unread,
Jan 13, 2021, 8:06:53 PM1/13/21
to dSIPRouter
Hi Sergio, I have two carriers and i need to send all my calls on one trunk to my fusionpbx. its only for inbound. this scenario is having one carrier send all their inbound calls to the other carrier trunk. one is charging me and the other is free. and the one that is free allows any call on that trunk. I just need at this very moment as this is very time sensitive. pls help!

Serge S

unread,
Jan 14, 2021, 12:22:35 PM1/14/21
to dSIPRouter
Hi Chico,

You give me too much credit ! I'm not the expert here... on the other hand, Richard is !

What you want is:

Carrier 1  -->                                        DSIPRouter   --> FusionPBX
Carrier 2 (FREE of charge) <-->  DSIPRouter <--> FusionPBX

On DSIPRouter side, it is quite straight forward. You have to setup 2 Carrier Groups + 2 Endpoint Groups ( Username/Password Auth - different credentials but same endpoints -> your fusion PBX ip/port I'm guessing), check Inbound DID Mapping & Global Outbound Routes (only to allow the free carrier I'm guessing ?)

Then on the fusionPBX side, you'll have to setup 2 trunks using what you've previously saved on your 2 Endpoint Groups. One trunk is only for Inbound calls, the other for both Inbount Outbound.

Can't tell for FusionPBX, I don't know it. I saw some specific parameters on Endpoint Group Details.

Sorry I'm not of a great help but I hope it could give some hints...
Reply all
Reply to author
Forward
0 new messages