<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi all,</p>
<p>I am writing to you again after a long time for a strange issue
in my Opensips 1.11 routing logic.</p>
<p>I have implemented a per-user call limit and i have to compare
current call value with max calls allowed:</p>
<pre>main() {
...
if (is_method("INVITE")) {
if (!create_dialog()) {
send_reply("500","Internal Server Error");
exit;
}
set_dlg_profile("call", "$rU"); # caller
set_dlg_profile("call", "$fU"); # called
get_profile_size("call", "$rU", "$var(calls)"); # What's the call limit for $rU?
## <-- CONCURRENT CALLS LIMIT BASED ON DESTINATION
if(avp_db_load("$ru/username","$avp(maxcalls)")) {
if($var(calls)>$avp(maxcalls)) {
xlog("L_INFO","$ci - User $rU has $var(calls) calls (max $avp(maxcalls) calls): BUSY\n");
sl_send_reply("486", "Busy: try later");
exit;
} else {
xlog("L_INFO","$ci - User $rU has $var(calls) calls (max $avp(maxcalls) calls): ALLOW\n");
}
} else {
xlog("L_INFO","$ci - User $rU has $var(calls) calls. NO LIMIT HERE\n");
}
# -->
...</pre>
<p>Seems that there's a problem with
"if($var(calls)>$avp(maxcalls))" because in logs i got:</p>
<pre>User XXXX has 2 calls (max 10 calls): BUSY
...
User XXXX has 1 calls (max 10 calls): ALLOW
</pre>
<p>Any hints or suggestion?</p>
Thanks for your help.
<pre class="moz-signature" cols="72">
--
Michele Pinassi
Università degli Studi di Siena
</pre>
</body>
</html>