[SR-Users] How to check a bit (1/0) of a pseudo-variable?

Iñaki Baz Castillo ibc at aliax.net
Thu Jun 16 14:03:52 CEST 2011


2011/6/16 Daniel-Constantin Mierla <miconda at gmail.com>:
> that function is probably for ser-like AVPs.
>
> back to your original need, you can use directly if conditions like:
>
> if($var(x) & 2) { ... }
>
> will be true if the second bit is set. You have to use the power of two for
> the appropriate integer value to match the bit position.The master branch has bitwise left/right shift operations as well

Ok, so the above example  if($var(x) & 2) { ... } will just work
because the number 2 has the bit 2 with value 1 (well, in fact the bit
1 as the first one is the bit 0). But if I want to compare the bit 5 I
need first to get 2^5 (for the second & operator) which I can get
using bitwise left/right shift functions, am I right? (since there is
no way in kamailio to calculate 2^N directly).

-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the sr-users mailing list