[SR-Users] CFGUtils module question

Fabian Borot fborot at hotmail.com
Fri Jun 1 01:25:17 CEST 2012


Txs a lot daniel, I got it now!







----------------------------------------
> Date: Thu, 31 May 2012 11:39:39 +0200
> From: miconda at gmail.com
> To: sr-users at lists.sip-router.org
> CC: fborot at hotmail.com
> Subject: Re: [SR-Users] CFGUtils module question
>
> 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