[OpenSIPS-Users] Dynamic Routing: dr_rules with the same prefix
Alexey
slackway2me at gmail.com
Mon Oct 14 18:58:29 UTC 2024
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/
More information about the Users
mailing list