[Serusers] Need easiest way to set/clear a flag and refer to it later in same call session

Miklos Tirpak miklos at iptel.org
Thu Feb 26 09:50:07 CET 2009


Hello,

for simple and very fast boolean checks you can use the flags:

- declare the flag(s) at the beginning of the config:

flags
	FLAG_FOO,
	FLAG_BAR;

- Call the setflag(FLAG_FOO) and resetflag(FLAG_FOO) functions to set 
and clear the flag when the INVITE is processed.
- Use "if (isflagset(FLAG_FOO)) {...}" to check the state of the flag in 
the reply route.

For storing integer or string values you can use AVPs:

# during INVITE processing
$foo = "myvalue";
$bar = 2;

# in reply_route:
if ($foo == "myvalue") {...}
if ($bar) {...}

Have a look at etc/ser-oob.cfg for examples. The values are attached to 
the transaction in both cases, therefore you need to forward the request 
with tm module.

Miklos

On 02/24/2009 06:40 AM, Frank Durda IV wrote:
> I need a simple way to set either a boolean flag (or integer
> value) during the INVITE of a given call in ser.cfg, and test
> that value via "if" elsehere in ser.cfg during the 183/200
> response messages for that same call.
> This would be a data object unique to a given call,
> which should disappear/lose persistence/end scope when
> a given call ends.  Not global, no need to write the
> value to disk, doesn't need to survive a restart of SER, etc.
> 
> The various SER documents describe a number of things that
> could do this, but most seem overly complex, storing the object
> in a MYSQL database on disk or something, and these all seem
> so excessive.  There also appear to be a few built-in flags,
> but the documentation suggests that all are actually there
> for specific uses and so use for other things might not work.
> 
> I simply want to make a determination of something during
> the INVITE for call 12345, and be able to refer to that
> flag or integer value later on when the various response
> messages for the same call (#12345) are coming back
> through.   I can't make the same determination on each
> message after the INVITE because the original src_ip
> address value where the INVITE came from doesn't seem
> to be in a testable variable when handling reply
> messages, or at least not in one that is clearly
> documented.
> 
> 
> I've chased a number of possible ways this might be done,
> but tire of being referred away from the doc that came with
> the source and over to web sites that tell me this or that module
> that might do part of what I need is deprecated and to use
> this other module, but the web site for the other module says
> that the first module is better suited to what I want to
> do (a circle), doesn't show how the set value can actually
> be tested, or the web page just doesn't work anymore.
> 
> So, assuming there is a simple way to do this, I need a
> quick code snip showing how to set/clear/assign a value to such
> a beast within INVITE handling, and a quick code snip of how
> to test it in an "if" statement during 183/200/110 type
> response messages.  Whatever it is, the value set, cleared
> or being tested in one call should not affect any other
> call.
> 
> 
> Thanks in advance!
> 
> 
> _______________________________________________
> Serusers mailing list
> Serusers at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers



More information about the sr-users mailing list