[OpenSIPS-Users] Compare $fU to drouting prefix

Mark Farmer farmorg at gmail.com
Fri Apr 17 14:58:46 EST 2020


OK, fixed it.

Turned out to be this breaking it by overwriting $acc_extra(customer_id)
with a blank value.

...
else $acc_extra(Call_Flow) = "Internal";
                $acc_extra(customer_id) = $var(rule_attrs);
...

Changed it to:

...
else if (isflagset(TPTY_PBX) || isflagset(PBX_TPTY)) {
                $acc_extra(Call_Flow) = "Internal";
                $acc_extra(customer_id) = $var(rule_attrs);
...

And all works nicely :)

Thanks for the help!
Mark.


On Fri, 17 Apr 2020 at 14:08, Mark Farmer <farmorg at gmail.com> wrote:

> Thats what I thought :)
>
> This is getting quite odd now.
> I am adding 2 extra fields, Call_Flow & customer_id. The odd thing is that
> Call_Flow is working perfectly in all cases.
> customer_id works fine for the latter 2 scenarios but in the first
> scenario the customer_id data is never added to the database.
>
> I have this configured for the acc module:
> modparam("acc", "extra_fields", "db: from_usr; to_usr; customer_id;
> Call_Flow")
>
> The variable is set earlier on:
> ...
> do_routing("3",,,"$var(custID)");
> ...
>
> And I am doing all of the accounting in a dedicated route:
>
> route[ACCEXTRA] {
>         do_accounting("db","cdr");
>         xlog("CUSTOM_LOG: Adding extra accounting: from_usr: $fU
> customer_id: $var(rule_attrs) $var(custID)"); *# variable is visible here*
>         $acc_extra(from_usr) = $fU;
>         $acc_extra(to_usr) = $tU;
>         if (isflagset(PBX_PSTN) || isflagset(TPTY_PSTN)) {
>                 xlog("CUSTOM_LOG: Customer ID = $var(custID)"); *#
> variable is visible here*
>                 $acc_extra(Call_Flow) = "Outbound";
>                 $acc_extra(customer_id) = $var(custID);
>                 xlog("CUSTOM_LOG: $$acc_extra(customer_id) =
> $acc_extra(customer_id)"); *# variable is visible here*
>         } else if (isflagset(PSTN_TPTY) || isflagset(PSTN_PBX)) {
>                 $acc_extra(Call_Flow) = "Inbound";
>                 $acc_extra(customer_id) = $var(rule_attrs);
>         } else $acc_extra(Call_Flow) = "Internal";
>                 $acc_extra(customer_id) = $var(rule_attrs);
> }
>
>
> On Fri, 17 Apr 2020 at 13:50, Bogdan-Andrei Iancu <bogdan at opensips.org>
> wrote:
>
>> Mark,
>>
>> You can populate the $acc_extra() from whatever other variable or string
>> operations. Most probably your issue is in other place, in regards to the
>> acc logic.
>>
>> Regards,
>>
>> Bogdan-Andrei Iancu
>>
>> OpenSIPS Founder and Developer
>>   https://www.opensips-solutions.com
>>
>> On 4/17/20 1:40 PM, Mark Farmer wrote:
>>
>> Thanks Bogdan, that's mostly working now.
>>
>> My issue now is with passing that identifier into acc_extra() as a
>> variable which does not seem to be working.
>> Using xlog() I can see that the variable is populated right before
>> calling acc_extra()
>>
>> ...
>> if (isflagset(PBX_PSTN) || isflagset(TPTY_PSTN)) {
>>                 xlog("CUSTOM_LOG: Customer ID = $var(custID)");
>>                 $acc_extra(customer_id) = $var(custID);
>> ...
>> do_accounting("db","cdr");
>> }
>>
>> Does acc_extra() not accept variables as input?
>>
>> Thanks again!
>> Mark.
>>
>>
>>
>>
>> On Fri, 17 Apr 2020 at 09:15, Bogdan-Andrei Iancu <bogdan at opensips.org>
>> wrote:
>>
>>> Hey Mark,
>>>
>>> It is not nice, but you can do:
>>>
>>> $var(tmp) = $rU;
>>> $rU = $fU
>>> do_routing();
>>> $rU = $var(tmp);
>>>
>>> Regards,
>>>
>>> Bogdan-Andrei Iancu
>>>
>>> OpenSIPS Founder and Developer
>>>   https://www.opensips-solutions.com
>>>
>>> On 4/17/20 11:13 AM, Mark Farmer wrote:
>>>
>>> Hi Bogdan, I will try to explain better.
>>>
>>> In rule_attrs I have a customer identifier which is used by acc to add
>>> the identifier into the CDR database.
>>> This works fine for calls from PSTN which are routed to another SIP
>>> gateway but calls from that gateway routed to PSTN can come from multiple
>>> customers and there is no way to identify which. So I'd like to match the
>>> incoming $fU to the rule that would match $rU in the from PSTN scenario in
>>> order to retrieve the rule_attrs (the customer identifier) from that rule.
>>>
>>> Does that make sense?
>>>
>>> Many thanks and regards
>>> Mark.
>>>
>>>
>>>
>>>
>>> On Thu, 16 Apr 2020 at 16:55, Bogdan-Andrei Iancu <bogdan at opensips.org>
>>> wrote:
>>>
>>>> Hi Mark,
>>>>
>>>> What kind of matching you want to do between $fU and the dr prefixes ?
>>>> You want to do the same as what drouting() does with $rU ?
>>>>
>>>> Regards,
>>>>
>>>> Bogdan-Andrei Iancu
>>>>
>>>> OpenSIPS Founder and Developer
>>>>   https://www.opensips-solutions.com
>>>>
>>>> On 4/16/20 6:14 PM, Mark Farmer wrote:
>>>>
>>>> Hi everyone
>>>>
>>>> I am looking for a way to compare $fU in INVITE to the matching
>>>> drouting() prefix of another group and retrieve the rule_attrs from that
>>>> rule.
>>>>
>>>> At the moment I am thinking I'll have to run a custom DB query so I
>>>> have 2 questions:
>>>>
>>>> 1. Is there a better way to do this?
>>>> 2. If not, what is the best way to run custom DB queries?
>>>>
>>>> I have been reading through the drouting() documentation but that
>>>> hasn't helped.
>>>>
>>>> OpenSIPS 2.4.7
>>>>
>>>> Many thanks!
>>>> Mark.
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing listUsers at lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>
>>>>
>>>>
>>>
>>> --
>>> Mark Farmer
>>> farmorg at gmail.com
>>>
>>>
>>>
>>
>> --
>> Mark Farmer
>> farmorg at gmail.com
>>
>>
>>
>
> --
> Mark Farmer
> farmorg at gmail.com
>


-- 
Mark Farmer
farmorg at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200417/e16213e2/attachment.html>


More information about the Users mailing list