Answering the call for feedback,<br><br>Script local flags are clear to me.<br><br>But I fail to see the clear benefits of transaction+branch(new) over the transaction+&quot;pseudo-branch&quot;(old) flags. Please correct me if wrong, but pseudo-branch flags:
<br>- inherit the (transaction) flags from route 0;<br>- are local to each branch: so if setflag(11) in branch_route of branch A, isflagset(11) will return false in branch_route of branch B (which is concurrent with A, but effectively runs &quot;after&quot; it - parallel fork);
<br>- are visible in replies routes: so if setflag(10) in onreply_route of branch A, isflagset(10) will return false in onreply_route of branch B (also in case that this reply of B comes after reply of A).<br><br>So, accounting, what I see as brand new - in pseudo-branch(old) vs. branch(new) - is having flags - of type new transaction/message - which are globally visible, in all request &amp; replies (&amp; failure?) routes. Any glaring error?
<br><br>Disclaimer: I only have a shallow understanding of flags, don&#39;t shoot the bullets to hard. :-)<br><br><br>WL.<br><br><div><span class="gmail_quote">On 1/9/07, <b class="gmail_sendername">Bogdan-Andrei Iancu</b>
 &lt;<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi everybody,
<br><br>Following some discussions with Juha regarding some extension for the<br>branch flags, we decided it is better to have a re-design of flags in<br>openser to allow a better flexibility and extensibility without any
<br>consistency penalties.<br><br>What we had so far:<br>&nbsp;&nbsp;&nbsp;&nbsp;- message flags (or transaction flags) which are transaction persistent<br>&nbsp;&nbsp;&nbsp;&nbsp;- pseudo-branch flags - a set of flags from the message flags were<br>handled by TM as branch flags
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (saved per branch and not only per transaction).<br><br>What we have now:<br>&nbsp;&nbsp;&nbsp;&nbsp;- message flags (or transaction flags) will works as they do now,<br>but the branch mask will be removed (rolling back as in 
0.9.x versions).<br>These flags are transaction persistent.<br>&nbsp;&nbsp;&nbsp;&nbsp;- branch flags (NEW) are saved also in transaction, but per branch;<br>also they will be saved in usrloc (per contact). A new set of functions<br>were added for manipulating these flags from script. So, there flags
<br>will be registration persistent and branch persistent.<br>&nbsp;&nbsp;&nbsp;&nbsp;- script flags (NEW) are no-message-related flags - they are only<br>script persistent and you can strictly use them for scripting. Once you<br>exit a top level route, they will be lost. These flags are useful and
<br>they offer an option to de-congest the message flags - many flags have<br>no need to be saved as they just reflect some scripting status.<br><br><br>What changes brings this:<br>&nbsp;&nbsp;&nbsp;&nbsp;- NAT flag will become a branch flag all the time.
<br>&nbsp;&nbsp;&nbsp;&nbsp;- you can have custom flags to be saved into usrloc (via branch flags).<br>&nbsp;&nbsp;&nbsp;&nbsp;- more flags in script (via script flags).<br><br>Corresponding Functions:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Message/transaction flags:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setflag(flag_idx)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resetflag(flag_idx)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isflagset(flag_idx)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Branch flags:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setbflag/setbranchflag(branch_idx,flag_idx)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resetbflag/resetbranchflag(branch_idx,flag_idx)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isbflagset/isbranchflagset(branch_idx,flag_idx)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or, the shorter format, working on the default (branch 0) flags:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setbflag(flag_idx)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resetbflag(flag_idx)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isbflagset(flag_idx)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Script flags:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setsflag/setscriptflag(flag_idx)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resetsflag/resetscriptflag(flag_idx)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; issflagset/isscriptflagset(flag_idx)<br><br><br><br>Flags and Pseudo Variables<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Message/transaction flags<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $mf (decimal) , $mF (hexa)<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Branch flags
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $bf (decimal) , $bF (hexa)<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Script flags<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sf (decimal) , $sF (hexa)<br><br><br><br>Flags and routes:<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Message/transaction flags<br><br>&nbsp;&nbsp;&nbsp;&nbsp; These flags will show up in all routes where messages related to
<br>the initial request are processed. So, they will be visible and<br>changeable in onbranch, failure and onreply routes; the flags will be<br>visible in all branch routes; if you change a flag in a branch route,<br>the next branch routes will inherit the change.
<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Branch flags<br><br>&nbsp;&nbsp;&nbsp;&nbsp; There flags will show up in all routes where messages related to<br>initial branch request are processed. So, in branch route you will see<br>different sets of flags (as they are different branches); in onreply
<br>route yo will see the branch flags corresponding to the branch the reply<br>belongs to; in failure route, the branch flags corresponding to the<br>branch the winning reply belongs to will be visible.<br>&nbsp;&nbsp;&nbsp;&nbsp; In request route, you can have multiple branches (as a result of a
<br>lookup(), enum query, append_branch(), etc) - the default branch is 0<br>(corresponding to the RURI); In reply routes there will be only one<br>branch , the 0 one. In branch route the default branch is the current<br>
process branch (having index 0); In failure route, initialy there is<br>only one branch (index 0), corresponding the the failed branch.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Script flags<br><br>&nbsp;&nbsp;&nbsp;&nbsp;There flags are available only in script and are reset after each
<br>top level route execution (routes internally triggered by OpenSER). They<br>will be persistent per main route, onreply_route, branch_route,<br>failure_route. Note they will be inherit in routes called from other routes.
<br><br><br><br>Example: nat flag handling<br><br>..........<br># 3 - the nat flag<br>modparam(&quot;usrloc&quot;,&quot;nat_bflag&quot;,3)<br>..........<br><br>route {<br>&nbsp;&nbsp;&nbsp;&nbsp;..........<br>&nbsp;&nbsp;&nbsp;&nbsp;if (nat detected)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setbflag(3); # set branch flag 3 for the branch 0
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;..........<br>&nbsp;&nbsp;&nbsp;&nbsp;if (is_method(&quot;REGISTER&quot;)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # the branch flags (including 3) will be saved into location<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; save(&quot;location&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;} else {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # lookup will load the branch flag from location
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!lookup(&quot;location&quot;)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sl_send_reply(&quot;404&quot;,&quot;Not Found&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t_on_branch(&quot;1&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t_relay();<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br>
<br>onbranch_route[1] {<br>&nbsp;&nbsp;&nbsp;&nbsp;xlog(&quot;-------branch=$T_branch_idx, branch flags=$bF\n&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;if (isbflagset(3)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #current branch is marked as natted<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .........<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>if no parallel forking is done, you can get rid of the branch route and
<br>add instead of t_on_branch():<br>&nbsp;&nbsp;&nbsp;&nbsp;........<br>&nbsp;&nbsp;&nbsp;&nbsp;if (isbflagset(3)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #current branch is marked as natted<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .........<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;.........<br><br><br><br>I will upload this description on the wiki page to be more accessible -
<br>in the mean while, any feedback (reports, better ideas, bugd) are welcome!<br><br>Regards,<br>Bogdan<br><br><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@openser.org">
Users@openser.org</a><br><a href="http://openser.org/cgi-bin/mailman/listinfo/users">http://openser.org/cgi-bin/mailman/listinfo/users</a><br></blockquote></div><br>