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+"pseudo-branch"(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 "after" 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 & replies (& failure?) routes. Any glaring error?
<br><br>Disclaimer: I only have a shallow understanding of flags, don'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>
<<a href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>> 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> - message flags (or transaction flags) which are transaction persistent<br> - pseudo-branch flags - a set of flags from the message flags were<br>handled by TM as branch flags
<br> (saved per branch and not only per transaction).<br><br>What we have now:<br> - 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> - 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> - 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> - NAT flag will become a branch flag all the time.
<br> - you can have custom flags to be saved into usrloc (via branch flags).<br> - more flags in script (via script flags).<br><br>Corresponding Functions:<br><br> Message/transaction flags:<br> setflag(flag_idx)
<br> resetflag(flag_idx)<br> isflagset(flag_idx)<br><br> Branch flags:<br> setbflag/setbranchflag(branch_idx,flag_idx)<br> resetbflag/resetbranchflag(branch_idx,flag_idx)<br> isbflagset/isbranchflagset(branch_idx,flag_idx)
<br> or, the shorter format, working on the default (branch 0) flags:<br> setbflag(flag_idx)<br> resetbflag(flag_idx)<br> isbflagset(flag_idx)<br><br> Script flags:<br> setsflag/setscriptflag(flag_idx)
<br> resetsflag/resetscriptflag(flag_idx)<br> issflagset/isscriptflagset(flag_idx)<br><br><br><br>Flags and Pseudo Variables<br><br> Message/transaction flags<br> $mf (decimal) , $mF (hexa)<br><br> Branch flags
<br> $bf (decimal) , $bF (hexa)<br><br> Script flags<br> $sf (decimal) , $sF (hexa)<br><br><br><br>Flags and routes:<br><br> Message/transaction flags<br><br> 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> Branch flags<br><br> 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> 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> Script flags<br><br> 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("usrloc","nat_bflag",3)<br>..........<br><br>route {<br> ..........<br> if (nat detected)<br> setbflag(3); # set branch flag 3 for the branch 0
<br><br> ..........<br> if (is_method("REGISTER")) {<br> # the branch flags (including 3) will be saved into location<br> save("location");<br> exit;<br> } else {<br> # lookup will load the branch flag from location
<br> if (!lookup("location")) {<br> sl_send_reply("404","Not Found");<br> exit;<br> }<br> t_on_branch("1")<br> t_relay();<br> }<br>}<br>
<br>onbranch_route[1] {<br> xlog("-------branch=$T_branch_idx, branch flags=$bF\n");<br> if (isbflagset(3)) {<br> #current branch is marked as natted<br> .........<br> }<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> ........<br> if (isbflagset(3)) {<br> #current branch is marked as natted<br> .........<br> }<br> .........<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>