On 05.08.2009 12:03 Uhr, Alex Balashov wrote:
Alex Balashov wrote:
Daniel-Constantin Mierla wrote:
IIRC, the mi command takes a bitmask as value
while the config
function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
This seems inconsistent and needlessly complicated and does not
follow from the documentation at all. I would recommend changing the
set_gflag MI function to take the bit offset as an argument rather
than the bitmask if is_gflag() checks the offset.
Well, OK, I take that back -- it does follow from the documentation,
if the parenthetical statements are payed careful attention. I still
think it should be changed on the MI side to be more consistent and
easier to work with.
The other problem with the current situation is that in order to set a
particular bit to 1 without wiping out any other flags that may have
been set in the past, it is necessary to first get the current value
from get_gflags and manually do the math. That's needlessly complex
for users who aren't programmers; not everybody has the powers of 2
and the common products of powers of 2 memorised.
indeed, awkward and this is prone
to errors and races if script sets
also the flag. Personally, I have been using $shv(x) to control config
behavior and there I dealt with values not flags.
Cheers,
Daniel
--
Daniel-Constantin Mierla
* SIP Router Bootcamp
* Kamailio (OpenSER) and Asterisk Training
* Berlin, Germany, Sep 1-4, 2009
*
http://www.asipto.com/index.php/sip-router-bootcamp/