[OpenSIPS-Users] Dynamic Routing: dr_rules with the same prefix

Ben Newlin Ben.Newlin at genesys.com
Tue Oct 15 14:29:12 UTC 2024


The drouting module supports the concept of groups for rules. The module can determine the group for the request automatically, or you can provide the group directly. You can determine the group based on the source and then drouting will only use the rules for that group.

Ben Newlin

From: Users <users-bounces at lists.opensips.org> on behalf of Alexey <slackway2me at gmail.com>
Date: Monday, October 14, 2024 at 3:00 PM
To: users at lists.opensips.org <users at lists.opensips.org>
Subject: [OpenSIPS-Users] Dynamic Routing: dr_rules with the same prefix
 EXTERNAL EMAIL - Please use caution with links and attachments

Hi list,

the situation is that there are 2 VoIP providers which send us INVITEs
with rU not in e164 format - just subscriber's phone number without country code
and without city code.

For example, a provider with the IP address 1.1.1.1 sends us 999999,
and a provider with the IP address 2.2.2.2 sends us 999999.

Our inner logic of incoming calls processing is based on the Drouting
module [1].
So we differentiate incoming calls by the username in the request-uri,
and it means that the column 'prefix' of the 'dr_rules' table [2] is used.
Then we fetch some useful (for us) extra data from the 'attrs' column
of the same table.

And this also means that there are 2 rules with the same 'prefix'.
If the INVITE is from provider/gateway 1.1.1.1 , we have to fetch
attrs of the first rule,
if the INVITE is from provider/gateway 2.2.2.2 , we have to fetch
attrs of the second rule.

Everything is clear if the prefix is unique.
But now I'm trying to understand what is the best way to fetch right attrs
when prefixes are the same.

The first idea is to use the 'routeid' parameter of the 'dr_rules' table -
go to some extra route in the script in case of some certain prefix matched,
'999999' in our case.
And then to check the source address of the INVITE in that route
and make some decision, depending on the $si:

route[routedr] {
        xlog("L_INFO", "[$ci] . cfg_line: $cfg_line . route $route .
call from specific gw $avp(dr_gw_id) with specific rU . src is
$si:$sp");

        # reset the value first.
        $var(rule_attrs)=NULL;

        # we know gw's IP addresses, from which we receive calls with
the same rU in INVITE.
        if( $si == "1.1.1.1" ) {
                $var(rule_attrs) = "Office-XXX 1333999999";
        } else {
                $var(rule_attrs) = "Office-YYY 1555999999";
        }
        xlog("L_INFO", "[$ci] . cfg_line: $cfg_line . route $route .
call from gw $avp(dr_gw_id) . src is $si:$sp . var rule_attrs is
$var(rule_attrs)");
}


But I'm not sure if this is the best way.
Maybe there is some more elegant solution.

[1] https://opensips.org/docs/modules/3.2.x/drouting.html
[2] https://www.opensips.org/Documentation/Install-DBSchema-3-2#GEN-DB-DR-RULES

--
best regards, Alexey
https://alexeyka.zantsev.com

_______________________________________________
Users mailing list
Users at lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20241015/71ae4943/attachment.html>


More information about the Users mailing list