Copyright © 2003 FhG FOKUS
Copyright © 2005 voice-system.ro
fr_timer
(integer)fr_inv_timer
(integer)wt_timer
(integer)delete_timer
(integer)retr_timer1p1
(integer)retr_timer1p2
(integer)retr_timer1p3
(integer)retr_timer2
(integer)noisy_ctimer
(integer)ruri_matching
(integer)via1_matching
(integer)unix_tx_timeout
(integer)restart_fr_on_each_reply
(integer)fr_timer_avp
(string)fr_inv_timer_avp
(string)tw_append
(string)branch_flag_mask
(string)t_newtran()
t_lookup_request()
t_relay_to_udp(ip, port)
,
t_relay_to_tcp(ip, port)
,
t_relay_to_tls(ip, port)
t_relay()
t_forward_nonack(ip, port)
t_forward_nonack_udp(ip, port)
t_forward_nonack_tcp(ip, port)
t_forward_nonack_tls(ip, port)
t_forward_nonack_uri()
t_reply(code, reason_phrase)
t_retransmit_reply()
t_replicate(ip, port)
t_replicate_udp(ip, port)
t_replicate_tcp(ip, port)
t_release()
t_check_status(re)
t_flush_flags()
t_local_replied(reply)
t_write_fifo(info,fifo)
t_write_unix(info,sock)
t_check_trans()
t_was_cancelled()
t_on_failure(failure_route)
t_on_reply(reply_route)
t_on_branch(branch_route)
load_tm(*import_structure)
fr_timer
parameterfr_inv_timer
parameterwt_timer
parameterdelete_timer
parameterretr_timer1p1
parameterretr_timer1p2
parameterretr_timer1p4
parameterretr_timer2
parameternoisy_ctimer
parameterruri_matching
parametervia1_matching
parameterunix_tx_timeout
parameterrestart_fr_on_each_reply
parameterfr_timer_avp
parameterfr_inv_timer_avp
parametertw_append
parameterbranch_flag_mask
parametert_newtran
usaget_lookup_request
usaget_relay_to_udp
usaget_relay
usaget_forward_nonack_xxx
usaget_reply
usaget_retransmit_reply
usaget_forward_replicate_xxx
usaget_release
usaget_check_status
usaget_flush_flags
usaget_local_replied
usaget_write_fifo/unix
usaget_check_trans
usaget_was_cancelled
usaget_on_failure
usaget_on_reply
usaget_on_branch
usageTM module enables stateful processing of SIP transactions. The main use of stateful logic, which is costly in terms of memory and CPU, is some services inherently need state. For example, transaction-based accounting (module acc) needs to process transaction state as opposed to individual messages, and any kinds of forking must be implemented statefully. Other use of stateful processing is it trading CPU caused by retransmission processing for memory. That makes however only sense if CPU consumption per request is huge. For example, if you want to avoid costly DNS resolution for every retransmission of a request to an unresolvable destination, use stateful mode. Then, only the initial message burdens server by DNS queries, subsequent retransmissions will be dropped and will not result in more processes blocked by DNS resolution. The price is more memory consumption and higher processing latency.
From user's perspective, there are these major functions : t_relay, t_relay_to_udp and t_relay_to_tcp. All of them setup transaction state, absorb retransmissions from upstream, generate downstream retransmissions and correlate replies to requests. t_relay forwards to current URI; (be it original request's URI or a URI changed by some of URI-modifying functions, such as sethost). t_relay_to_udp and t_relay_to_tcp forward to a specific address over UDP or TCP respectively.
In general, if TM is used, it copies clones of received SIP messages in shared memory. That costs the memory and also CPU time (memcpys, lookups, shmem locks, etc.) Note that non-TM functions operate over the received message in private memory, that means that any core operations will have no effect on statefully processed messages after creating the transactional state. For example, calling record_route after t_relay is pretty useless, as the RR is added to privately held message whereas its TM clone is being forwarded.
TM is quite big and uneasy to program--lot of mutexes, shared memory access, malloc & free, timers--you really need to be careful when you do anything. To simplify TM programming, there is the instrument of callbacks. The callback mechanisms allow programmers to register their functions to specific event. See t_hooks.h for a list of possible events.
Other things programmers may want to know is UAC--it is a very simplistic code which allows you to generate your own transactions. Particularly useful for things like NOTIFYs or IM gateways. The UAC takes care of all the transaction machinery: retransmissions , FR timeouts, forking, etc. See t_uac prototype in uac.h for more details. Who wants to see the transaction result may register for a callback.
First what is the idea with the branch concept: branch route is a route to be execute separately for each branch before being sent out - changes in that route should reflect only on that branch.
There are two types of flags in OpenSER :
global flags - global because they are visible everywhere in the transaction (in all routes and in all sequential replies/request).
branch flags - flags that are visible only from a specific branch - in all replies and routes connected to this branch.
For example: I have a call parallel forking to GW and to a user. And I would like to know from which branch I will get the final negative reply (if so). I will set a branch route before relaying the calls (with the 2 branches). The branch route will be separately executed for each branch; in the branch going to GW (I can identified it by looking to RURI), I will set a branch flag. This flag will appear only in the onreply route run for replied from GW. It will be also be visible in failure route if the final elected reply belongs to the GW branch. This flags will not be visible in the other branch (in routes executing replies from the other branch).
For how to define branch flags and use via script, see Section 1.3.17 and Section 1.4.18.
Also, modules may set branch flags before transaction creation (for the moment this feature is not available in script). The REGISTRAR module is the first to use this feature. If the "use_branch_flags" param is enabled, the NAT flag will be push in branch flags instead in message flags - IMPORTANT: be sure that NAT flag is in the range of the branch flags ad defined in TM. Using this, NAT traversal per branch may be implemented.
The following modules must be loaded before this module:
No dependencies on other OpenSER modules.
The following libraries or applications must be installed before running OpenSER with this module loaded:
None.
fr_timer
(integer)Timer which hits if no final reply for a request or ACK for a negative INVITE reply arrives (in seconds).
Default value is 30 seconds.
fr_inv_timer
(integer)Timer which hits if no final reply for an INVITE arrives after a provisional message was received (in seconds).
Default value is 120 seconds.
wt_timer
(integer)Time for which a transaction stays in memory to absorb delayed messages after it completed; also, when this timer hits, retransmission of local cancels is stopped (a puristic but complex behavior would be not to enter wait state until local branches are finished by a final reply or FR timer--we simplified).
Default value is 5 seconds.
delete_timer
(integer)Time after which a to-be-deleted transaction currently ref-ed by a process will be tried to be deleted again.
Default value is 2 seconds.
noisy_ctimer
(integer)If set, on FR timer INVITE transactions will be explicitly canceled if possible, silently dropped otherwise. Preferably, it is turned off to allow very long ringing. This behavior is overridden if a request is forked, or some functionality explicitly turned it off for a transaction (like acc does to avoid unaccounted transactions due to expired timer).
Default value is 0 (false).
ruri_matching
(integer)Should be request-uri matching used as a part of pre-3261 transaction matching as the standard wants us to do so? Turn only off for better interaction with devices that are broken and send different r-uri in CANCEL/ACK than in original INVITE.
Default value is 1 (true).
via1_matching
(integer)Should be top most VIA matching used as a part of pre-3261 transaction matching as the standard wants us to do so? Turn only off for better interaction with devices that are broken and send different top most VIA in CANCEL/ACK than in original INVITE.
Default value is 1 (true).
unix_tx_timeout
(integer)Send timeout to be used by function which use UNIX sockets (as t_write_unix).
Default value is 2 seconds.
restart_fr_on_each_reply
(integer)If true (non null value), the final response timer will be re-triggered for each received provisional reply. In this case, final response timeout may occure after a time longe than fr_inv_timer (if UAS keeps sending provisional replies)
Default value is 1 (true).
fr_timer_avp
(string)Full specification (NAME, ID, Alias) of an AVP which contains a final response timeout value. If present, ths value will overeide the static fr_timer parameter.
If set to empty string, the whole mechanism for variable timeout will be disabled, falling back to the static value.
Default value is "callee_fr_timer".
fr_inv_timer_avp
(string)Full specification (NAME, ID, Alias) of an AVP which contains a final INVITE response timeout value. If present, ths value will overeide the static fr_inv_timer parameter.
If set to empty string, the whole mechanism for variable timeout will be disabled, falling back to the static value.
Default value is "callee_fr_inv_timer".
tw_append
(string)List of additional information to be appended by t_write_fifo and t_write_unix functions.
Default value is null string.
Syntax of the parameter is:
tw_append = append_name':' element (';'element)*
element = ( [name '='] pseudo_variable)
The full list of supported pseudo-variables in OpenSER is availabe at: http://openser.org/docs/pseudo-variables.html
Each element will be appended per line in "name: value" format. Element "$rb (message body)" is the only one which does not accept name; the body it will be printed all the time at the end, disregarding its position in the definition string.
branch_flag_mask
(string)Defined which flags shall be as branch flags. The branch flags will be visible only in the messages belonging to that branch (in branch, onreply and failure route). The global flags are visible for all messages of the corresponding transaction.
The value of the parameter is a 32-bits mask. It may be defined using 2, 10 or 16 bases.
Default value is NULL (no branch flags, all being global).
t_newtran()
Creates a new transaction, returns a negative value on error. This is the only way a script can add a new transaction in an atomic way. Typically, it is used to deploy a UAS.
NOTE that the changes on the request that are made after this function call will not be saved into transaction!!! |
This function can be used from REQUEST_ROUTE.
t_lookup_request()
Checks if a transaction exists. Returns a positive value if so,
negative otherwise. Most likely you will not want to use it, as a
typical application of a looku-up is to introduce a new transaction if
none was found. However this is safely (atomically) done using
t_newtran
.
This function can be used from REQUEST_ROUTE.
t_relay_to_udp(ip, port)
,
t_relay_to_tcp(ip, port)
,
t_relay_to_tls(ip, port)
Relay a message statefully to a fixed destination. This along with
t_relay
is the function most
users want to use--all other are mostly for programming. Programmers
interested in writing TM logic should review how
t_relay is implemented in tm.c and how TM
callbacks work.
Meaning of the parameters is as follows:
ip - IP address where the message should be sent.
port - Port number.
This functions can be used from REQUEST_ROUTE, FAILURE_ROUTE.
t_relay()
Relay a message statefully to destination indicated in current URI. (If the original URI was rewritten by UsrLoc, RR, strip/prefix, etc., the new URI will be taken). Returns a negative value on failure--you may still want to send a negative reply upstream statelessly not to leave upstream UAC in lurch.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
t_forward_nonack(ip, port)
t_forward_nonack_udp(ip, port)
t_forward_nonack_tcp(ip, port)
t_forward_nonack_tls(ip, port)
t_forward_nonack_uri()
Similar to t_relay() but it expects the transaction to be aleady created - this why it cannot handle ACK (which are statelessly forwarded). It should be used along with t_newtran().
Meaning of the parameters is as follows:
ip - IP address where the message should be sent.
port - Port number.
t_forward_nonack_uri() will determin the detination address (proto:IP:port) based on the RURI.
This functions can be used from REQUEST_ROUTE.
t_reply(code, reason_phrase)
Sends a stateful reply after a transaction has been established. See
t_newtran
for usage.
Meaning of the parameters is as follows:
code - Reply code number.
reason_phrase - Reason string.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
t_retransmit_reply()
Retransmits a reply sent previously by UAS transaction.
This function can be used from REQUEST_ROUTE.
t_replicate(ip, port)
t_replicate_udp(ip, port)
t_replicate_tcp(ip, port)
Replicates a request to another address. No information due the replicated request (like reply code) will be forwarded to the original SIP UAC.
Meaning of the parameters is as follows:
ip - IP address where the message should be sent.
port - Port number.
This functions can be used from REQUEST_ROUTE.
t_release()
Remove transaction from memory (it will be first put on a wait timer to absorb delayed messages).
This function can be used from REQUEST_ROUTE.
t_check_status(re)
Returns true if the regualr expresion "re" match the reply code of the response message as follows:
in routing block - the code of the last sent reply.
in on_reply block - the code of the current received reply.
in on_failure block - the code of the selected negative final reply.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE.
t_flush_flags()
Flush the flags from current request into the already created transaction. It make sens only in routing block if the trnasaction was created via t_newtran() and the flags have been altered since.
This function can be used from REQUEST_ROUTE.
t_local_replied(reply)
Returns true if all or last (depending of the parameter) reply(es) were local generated (and not received).
Parameter may be "all" or "last".
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE.
t_write_fifo(info,fifo)
t_write_unix(info,sock)
Write via FIFO file or UNIX socket a lot of information regarding the request. Which information should be written may be control via the "tw_append" parameter.
This functions can be used from REQUEST_ROUTE, FAILURE_ROUTE.
t_check_trans()
Returns true if the current request is associated to a transaction. The relationship between the request ans transaction is defined as follow:
non-CANCEL/non-ACK requests - is true if the request belongs to a transaction; if so, it means that the request is a retransmision.
CANCEL request - true if the cancelled INVITE transaction exists.
ACK request - true if the ACK is a local end-to-end ACK for an existent INVITE transaction.
This function can be used from REQUEST_ROUTE.
t_was_cancelled()
Retuns true if called for an INVITE transaction that was explicitly cancelled by UAC side via a CANCEL request.
This function can be used from ONREPLY_ROUTE, FAILURE_ROUTE.
t_on_failure(failure_route)
Sets reply routing block, to which control is passed after a transaction completed with a negative result but before sending a final reply. In the referred block, you can either start a new branch (good for services such as forward_on_no_reply) or send a final reply on your own (good for example for message silo, which received a negative reply from upstream and wants to tell upstream "202 I will take care of it").
As not all functions are available from failure route, please check the documentation for each function to see the permissions. Any other commands may result in unpredictable behavior and possible server failure.
Note that whenever failure_route is entered, RURI is set to value of the winning branch.
Meaning of the parameters is as follows:
failure_route - Reply route block to be called.
t_on_reply(reply_route)
Sets reply routing block, to which control is passed each time a reply (provisional or final) for the transaction is received. The route is not called for local generated replies! In the referred block, you can inspect the reply and perform text operations on it.
As not all functions are available from this type of route, please check the documentation for each function to see the permissions. Any other commands may result in unpredictable behavior and possible server failure.
If the processed reply is provisionla reply (1xx code), by calling the drop() function (exported by core), the execution of the route will end and the reply will not be forwarded further.
Meaning of the parameters is as follows:
reply_route - Reply route block to be called.
t_on_branch(branch_route)
Sets a branch route to be execute separately for each branch of the transaction before being sent out - changes in that route should reflect only on that branch.
As not all functions are available from this type of route, please check the documentation for each function to see the permissions. Any other commands may result in unpredictable behavior and possible server failure.
The per-branch flags which are modified in the branch route will be visible only in the replies related to that branch. See Section 1.3.17 also.
By calling the drop() function (exported by core), the execution of the branch route will end and the branch will not be forwarded further.
Meaning of the parameters is as follows:
branch_route - Branch route block to be called.
load_tm(*import_structure)
For programmatic use only--import the TM API. See the cpl-c, acc or jabber modules to see how it works.
Meaning of the parameters is as follows:
import_structure - Pointer to the import structure - see "struct tm_binds" in modules/tm/tm_load.h
Take a look at http://openser.org/.
First at all check if your question was already answered on one of our mailing lists:
User Mailing List - http://openser.org/cgi-bin/mailman/listinfo/users
Developer Mailing List - http://openser.org/cgi-bin/mailman/listinfo/devel
E-mails regarding any stable OpenSER release should be sent to
<users@openser.org>
and e-mails regarding development versions
should be sent to <devel@openser.org>
.
If you want to keep the mail private, send it to
<team@openser.org>
.
Please follow the guidelines provided at: http://openser.org/bugs.