[SR-Users] CFGUtils module question

Daniel-Constantin Mierla miconda at gmail.com
Thu May 31 11:39:39 CEST 2012


Hello,

On 5/30/12 11:33 PM, Fabian Borot wrote:
>
> Hello
>
>   
>
> Can somebody help me understand the example given with MI command "is_gflag"?
>
>   
>
>   
>
> ...
> $ kamctl fifo set_gflag 1024
> $ kamctl fifo is_gflag 1024
> TRUE
> $ kamctl fifo is_gflag 1025
> TRUE
> $ kamctl fifo is_gflag 1023
> FALSE
> $ kamctl fifo set_gflag 0x10
> $ kamctl fifo is_gflag 1023
> TRUE
> $ kamctl fifo is_gflag 1007
> FALSE
> $ kamctl fifo is_gflag 16
> TRUE
>
>
> This is how I understand it. There are 32 posible flags (0..31), each one can be set independently. The commands "is_flag" and "set_gflag" expect a bitmask as value (decimal or hex)
>
>   
>
> If I set "kamctl fifo set_gflag 1024", this means "100 0000 0000", I expect that the only flag that has been set to 1 is the position 10. How come the command "kamctl fifo is_gflag 1025" which is "100 0000 0001" can yield TRUE?. I expect it to be TRUE only if flags 0 and 10 are both set to 1.
>
>   
>
> Same thing with setting the flag to 0x10 (16 in decimal, "1 0000" in binary), how come the "is_gflag 1023 and is_gflag 1007" can return TRUE?
the test is done as bitwise AND operations and returns true if the 
result is not zero, meaning at least one of the flags is set.

Like: if(checkval & gflags) { return true} else {return false}

Cheers,
Daniel

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Seattle, USA, Sep 23-26, 2012 - http://asipto.com/u/katu
Kamailio Practical Workshop, Netherlands, Sep 10-12, 2012 - http://asipto.com/u/kpw






More information about the sr-users mailing list