Resources.DocsCoreFlags History

Hide minor edits - Show changes to markup

April 24, 2013, at 10:03 PM by 92.80.24.181 -
Changed lines 1-140 from:

Resources -> Documentation -> CookBooks -> Scripting Flags


(:toc-float Table of Content:)

This documentation is valid for OpenSIPS v1.10.x / devel

Types of flags

  • message flags (or transaction flags) these flags are transaction persistent. They are visible in all routes and cases where the transaction context is visible
  • branch flags are saved also in transaction, but per branch; also they will be saved in usrloc (per contact). A new set of functions were added for manipulating these flags from script. So, there flags will be registration persistent and branch persistent.
  • script flags are no-message-related flags - they are only script persistent and you can strictly use them for scripting. Once you exit a top level route, they will be lost. These flags are useful and they offer an option to de-congest the message flags - many flags have no need to be saved as they just reflect some scripting status.

Corresponding Functions

Message/transaction flags

setflag(flag_idx) resetflag(flag_idx) isflagset(flag_idx)

Branch flags

setbflag/setbranchflag(branch_idx,flag_idx) resetbflag/resetbranchflag(branch_idx,flag_idx) isbflagset/isbranchflagset(branch_idx,flag_idx)

or, the shorter format, working on the default (branch 0) flags:

setbflag(flag_idx) resetbflag(flag_idx) isbflagset(flag_idx)

Script flags

setsflag/setscriptflag(flag_idx) resetsflag/resetscriptflag(flag_idx) issflagset/isscriptflagset(flag_idx)


Flags and Pseudo Variables

Message/transaction flags

$mf - decimal value $mF - hexa value

Branch flags

$bf - decimal value $bF - hexa value

Script flags

$sf - decimal value $sF - hexa valu


Flags and routes

Message/transaction flags

These flags will show up in all routes where messages related to the initial request are processed. So, they will be visible and changeable in onbranch, failure and onreply routes; the flags will be visible in all branch routes; if you change a flag in a branch route, the next branch routes will inherit the change.

Branch flags

There flags will show up in all routes where messages related to initial branch request are processed. So, in branch route you will see different sets of flags (as they are different branches); in onreply route yo will see the branch flags corresponding to the branch the reply belongs to; in failure route, the branch flags corresponding to the branch the winning reply belongs to will be visible. In request route, you can have multiple branches (as a result of a lookup(), enum query, append_branch(), etc) - the default branch is 0 (corresponding to the RURI); In reply routes there will be only one branch , the 0 one. In branch route the default branch is the current process branch (having index 0); In failure route, initially there is only one branch (index 0), corresponding the failed branch.

Script flags

There flags are available only in script and are reset after each top level route execution (routes internally triggered by OpenSIPS). They will be persistent per main route, onreply_route, branch_route, failure_route. Note they will be inherit in routes called from other routes.


Example

Nat flag handling

 ..........
 # 3 - the nat flag
 modparam("usrloc","nat_bflag",3)
 ..........

 route {
   ..........
   if (nat detected)
      setbflag(3); # set branch flag 3 for the branch 0

   ..........
   if (is_method("REGISTER")) {
      # the branch flags (including 3) will be saved into location
      save("location");
      exit;
   } else {
      # lookup will load the branch flag from location
      if (!lookup("location")) {
         sl_send_reply("404","Not Found");
         exit;
      }
      t_on_branch("1")
      t_relay();
   }
 }

 branch_route[1] {
   xlog("-------branch=$T_branch_idx, branch flags=$bF\n");
   if (isbflagset(3)) {
      #current branch is marked as natted
      .........
   }
 }

if no parallel forking is done, you can get rid of the branch route and add instead of t_on_branch():

   ........
   if (isbflagset(3)) {
      #current branch is marked as natted
      .........
   }
   ......... 

(:commentboxchrono:)

to:

(:redirect Documentation/Script-Flags quiet=1:)

January 29, 2013, at 06:35 PM by vlad_paiu -
Changed line 5 from:

This documentation is valid for OpenSIPS v1.9.x / devel

to:

This documentation is valid for OpenSIPS v1.10.x / devel

November 28, 2012, at 11:22 AM by bogdan -
Deleted lines 138-143:

(:nl:)>>messagehead<<

Carl?27 November 2012, 02:22

Now I feel stupid. That's claered it up for me

November 27, 2012, at 03:22 AM by Carl - Comment added
Added lines 139-144:

(:nl:)>>messagehead<<

Carl?27 November 2012, 02:22

Now I feel stupid. That's claered it up for me

March 22, 2012, at 01:56 PM by vlad_paiu -
Changed line 5 from:

This documentation is valid for OpenSIPS v1.8.x / devel

to:

This documentation is valid for OpenSIPS v1.9.x / devel

July 12, 2011, at 07:56 PM by bogdan -
Changed line 5 from:

This documentation is valid for OpenSIPS v1.7.x / devel

to:

This documentation is valid for OpenSIPS v1.8.x / devel

May 12, 2011, at 12:30 PM by bogdan - Comments Cleanup
Deleted lines 138-143:

(:nl:)>>messagehead<<

Olivia?11 May 2011, 16:37

Glad I've failnly found something I agree with!

May 11, 2011, at 05:37 PM by Olivia - Comment added
Added lines 139-144:

(:nl:)>>messagehead<<

Olivia?11 May 2011, 16:37

Glad I've failnly found something I agree with!

May 11, 2011, at 10:13 AM by bogdan - Comments Cleanup
Deleted lines 138-150:

(:nl:)>>messagehead<<

Amberlee?10 May 2011, 11:30

AKAIK you've got the ansewr in one!

(:nl:)>>messagehead<<

Cathleen?11 May 2011, 02:00

Superior tihkning demonstrated above. Thanks!

May 11, 2011, at 03:00 AM by Cathleen - Comment added
Added lines 145-150:

(:nl:)>>messagehead<<

Cathleen?11 May 2011, 02:00

Superior tihkning demonstrated above. Thanks!

May 10, 2011, at 12:30 PM by Amberlee - Comment added
Added lines 140-145:

(:nl:)>>messagehead<<

Amberlee?10 May 2011, 11:30

AKAIK you've got the ansewr in one!

October 14, 2009, at 12:41 AM by bogdan -
Changed line 5 from:

This documentation is valid for OpenSIPS v1.6.x / devel

to:

This documentation is valid for OpenSIPS v1.7.x / devel

April 23, 2009, at 11:33 AM by bogdan -
Changed line 2 from:
to:

Added lines 4-6:

This documentation is valid for OpenSIPS v1.6.x / devel

March 03, 2009, at 11:48 AM by bogdan -
Changed lines 133-138 from:

@]

to:

@]


(:commentboxchrono:)

November 25, 2008, at 07:22 PM by Chevio Mercado - spell check
Changed line 7 from:
  • message flags (or transaction flags) these flags are transaction persistent. They are vizible in all routes and cases where the transaction contect is visible
to:
  • message flags (or transaction flags) these flags are transaction persistent. They are visible in all routes and cases where the transaction context is visible
October 08, 2008, at 09:45 AM by 81.180.102.217 -
Changed lines 1-2 from:

Resources -> Documentation -> Scripting Flags

to:

Resources -> Documentation -> CookBooks -> Scripting Flags

October 03, 2008, at 01:52 PM by 81.180.102.217 -
Added lines 3-4:

(:toc-float Table of Content:)

August 02, 2008, at 11:09 PM by 92.80.65.247 -
Changed line 9 from:
to:

Changed line 38 from:
to:

Changed line 58 from:
to:

Changed line 81 from:
to:

August 02, 2008, at 11:09 PM by 92.80.65.247 -
Added lines 1-2:

Resources -> Documentation -> Scripting Flags

August 02, 2008, at 11:08 PM by 92.80.65.247 -
Added lines 1-129:

Types of flags

  • message flags (or transaction flags) these flags are transaction persistent. They are vizible in all routes and cases where the transaction contect is visible
  • branch flags are saved also in transaction, but per branch; also they will be saved in usrloc (per contact). A new set of functions were added for manipulating these flags from script. So, there flags will be registration persistent and branch persistent.
  • script flags are no-message-related flags - they are only script persistent and you can strictly use them for scripting. Once you exit a top level route, they will be lost. These flags are useful and they offer an option to de-congest the message flags - many flags have no need to be saved as they just reflect some scripting status.

Corresponding Functions

Message/transaction flags

setflag(flag_idx) resetflag(flag_idx) isflagset(flag_idx)

Branch flags

setbflag/setbranchflag(branch_idx,flag_idx) resetbflag/resetbranchflag(branch_idx,flag_idx) isbflagset/isbranchflagset(branch_idx,flag_idx)

or, the shorter format, working on the default (branch 0) flags:

setbflag(flag_idx) resetbflag(flag_idx) isbflagset(flag_idx)

Script flags

setsflag/setscriptflag(flag_idx) resetsflag/resetscriptflag(flag_idx) issflagset/isscriptflagset(flag_idx)

Flags and Pseudo Variables

Message/transaction flags

$mf - decimal value $mF - hexa value

Branch flags

$bf - decimal value $bF - hexa value

Script flags

$sf - decimal value $sF - hexa valu

Flags and routes

Message/transaction flags

These flags will show up in all routes where messages related to the initial request are processed. So, they will be visible and changeable in onbranch, failure and onreply routes; the flags will be visible in all branch routes; if you change a flag in a branch route, the next branch routes will inherit the change.

Branch flags

There flags will show up in all routes where messages related to initial branch request are processed. So, in branch route you will see different sets of flags (as they are different branches); in onreply route yo will see the branch flags corresponding to the branch the reply belongs to; in failure route, the branch flags corresponding to the branch the winning reply belongs to will be visible. In request route, you can have multiple branches (as a result of a lookup(), enum query, append_branch(), etc) - the default branch is 0 (corresponding to the RURI); In reply routes there will be only one branch , the 0 one. In branch route the default branch is the current process branch (having index 0); In failure route, initially there is only one branch (index 0), corresponding the failed branch.

Script flags

There flags are available only in script and are reset after each top level route execution (routes internally triggered by OpenSIPS). They will be persistent per main route, onreply_route, branch_route, failure_route. Note they will be inherit in routes called from other routes.

Example

Nat flag handling

 ..........
 # 3 - the nat flag
 modparam("usrloc","nat_bflag",3)
 ..........

 route {
   ..........
   if (nat detected)
      setbflag(3); # set branch flag 3 for the branch 0

   ..........
   if (is_method("REGISTER")) {
      # the branch flags (including 3) will be saved into location
      save("location");
      exit;
   } else {
      # lookup will load the branch flag from location
      if (!lookup("location")) {
         sl_send_reply("404","Not Found");
         exit;
      }
      t_on_branch("1")
      t_relay();
   }
 }

 branch_route[1] {
   xlog("-------branch=$T_branch_idx, branch flags=$bF\n");
   if (isbflagset(3)) {
      #current branch is marked as natted
      .........
   }
 }

if no parallel forking is done, you can get rid of the branch route and add instead of t_on_branch():

   ........
   if (isbflagset(3)) {
      #current branch is marked as natted
      .........
   }
   ......... 

Page last modified on April 24, 2013, at 10:03 PM