[OpenSIPS-Users] CGRates MaxUsage Disconnection
HS
bullehs at gmail.com
Sun May 4 21:26:51 UTC 2025
Hi all,
I was wondering if anyone has any experience with CGRateS. I'm trying to
disconnect calls after MaxUsage expiry. All the examples I found show the
following snippet is enough and should work automagically to disconnect the
call, but doesn't seem to work for me.
Appreciate the help.
#### CGRateS module
loadmodule "dialog.so"
loadmodule "cgrates.so"
modparam("cgrates", "cgrates_engine", "127.0.0.1:2014")
route [resume_cgr_auth] {
$var(rc) = $rc;
# with GetMaxUsage == false, cgrates_auth() returns -2 on success
if ($var(rc) < 0 && ($cgr_ret(MaxUsage) != 0 || $var(rc) != -2)) {
xlog("L_NOTICE", "[$ci] CGRateS auth failed: rc=$var(rc), code=$cgr_ret\n");
send_reply(403, "Forbidden");
exit;
}
# Set the returned attributes from CGRateS as script pseudovariables
$var(idx) = 0;
while ($(cgr_ret(AttributesDigest){s.select,$var(idx),,}) != NULL) {
$avp($(cgr_ret(AttributesDigest){s.select,$var(idx),,}{s.select,0,:}))
= $(cgr_ret(AttributesDigest){s.select,$var(idx),,}{s.select,1,:});
$var(idx) = $var(idx) + 1;
}
# Enable CDRs being sent to CGRateS
cgrates_acc("cdr|missed", "$fU", "$rU");
if ( $cgr_ret(RoutesDigest)==NULL ) { # no routing requested
route(relay);
}
xlog("L_INFO", "[$ci] CGRateS auth OK, with routes:
<$cgr_ret(RoutesDigest)>\n");
$avp(carriers) := $cgr_ret(RoutesDigest);
$avp(carriers_idx) := 0;
route( to_carriers );
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20250505/721cf397/attachment.html>
More information about the Users
mailing list