[OpenSIPS-Users] [NEW] Stateless and stateful replies - script handling

Bogdan-Andrei Iancu bogdan at voice-system.ro
Tue Nov 18 12:04:43 CET 2008


Hi,

Using the new signalling module added by Anca, the reply handling is now 
more simpler (from script and from the modules sending replies).

The issue that was solved is that all the modules were sending stateless 
replies (internally). But from script, because of retransmissions (when 
long processing for requests happened), many script writers were forcing 
statefull processing (via t_newtran()) . This was leading to a bogus 
behaviour (a mixture of stateless and stateful for the same requests) - 
even if the transaction was created, the modules were internally sending 
stateless replies, so the transaction was not updated. When a request 
retransmission come, the Tm was detecting it and was trying to send the 
last reply sent (as per RFC3261), but the TM was not aware of an reply, 
so the request is simply discarded - and this mixture of stateless and 
stateful breaks the SIP specs.

Typical example of how stateless/statful was used so far - if the 
authentication processes take too long (DB, LDAP, etc delays), you want 
to create the transaction for stoping the request retransmissions to hit 
again the script processing:

            t_newtran(); /* statefull processing */

            if (!www_authorize("", "subscriber")) {
                www_challenge("", "0"); /* stateless processing */
                t_release();
                exit;
            };

This approach is currently used to protect (from processing the 
retransmissions as normal request) several key points in scripts, like 
authentication, registration, etc.

Now, all the modules are using the signaling module for sending replies. 
This module is able to detect if a transaction was created or not and 
use the appropriate way of sending replies (via TM or SL). All this 
transparent for the script writer.

So, in the new form:

            t_newtran(); /* statefull processing */

            if (!www_authorize("", "subscriber")) {
                www_challenge("", "0"); /* stateful processing */
                exit;
            };

when the auth module sends the challenge, the reply will go statefully 
(because the transaction was created via t_newtran() ). More or less, if 
you create the transaction, all the following functions/module will 
automatically switch to stateful processing.

Note that the signaling module also exports a script function send_reply :
    http://www.opensips.org/html/docs/modules/devel/signaling.html#id2525120
This function also sends the reply statefull or stateless, depending if 
a transaction exists or not.
It is highly recommended  to start using this function instead of 
sl_send_reply() and t_reply() !

This change is part of a larger plan of consolidating all the existing 
functionalities from OpenSIPS in a way to make them easier to use and 
compliant in the same time.

Regards,
Bogdan



More information about the Users mailing list