Skip to content

Commit

Permalink
fix sst dialog timeout after timeout_avp removal
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Mar 18, 2014
1 parent b91cba4 commit a65eca9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 163 deletions.
10 changes: 8 additions & 2 deletions modules/dialog/dlg_handlers.c
Expand Up @@ -1221,12 +1221,18 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
LM_DBG("sequential request successfully processed (dst_leg=%d)\n",
dst_leg);

if (dlg_tmp_timeout != -1 && dlg_tmp_timeout_id == req->id) {
dlg->lifetime = dlg_tmp_timeout;
dlg->lifetime_dirty = 1;
} else {
dlg->lifetime_dirty = 0;
}

/* within dialog request */
run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, dir, 0);

/* update timer during sequential request? */
if (dlg_tmp_timeout != -1 && dlg_tmp_timeout_id == req->id) {
dlg->lifetime = dlg_tmp_timeout;
if (dlg->lifetime_dirty) {
if (update_dlg_timer( &dlg->tl, dlg->lifetime )==-1)
LM_ERR("failed to update dialog lifetime\n");
}
Expand Down
1 change: 1 addition & 0 deletions modules/dialog/dlg_hash.h
Expand Up @@ -113,6 +113,7 @@ struct dlg_cell
unsigned int h_entry;
unsigned int state;
unsigned int lifetime;
unsigned int lifetime_dirty; /* 1 if lifetime timer should be updated */
unsigned int start_ts; /* start time (absolute UNIX ts)*/
unsigned int flags;
unsigned int from_rr_nb;
Expand Down
52 changes: 11 additions & 41 deletions modules/sst/README
Expand Up @@ -29,9 +29,8 @@ Ron Winacott
1.4.1. enable_stats (integer)
1.4.2. min_se (integer)
1.4.3. sst_interval (integer)
1.4.4. timeout_avp (string)
1.4.5. reject_to_small (integer)
1.4.6. sst_flag (string/integer)
1.4.4. reject_to_small (integer)
1.4.5. sst_flag (string/integer)

1.5. Exported Functions

Expand All @@ -41,18 +40,15 @@ Ron Winacott

1.6.1. expired_sst

1.7. Installation and Running

List of Examples

1.1. Session timer call flow
1.2. Set enable_stats parameter
1.3. Set min_se parameter
1.4. Set sst_interval parameter
1.5. Set timeout_avp parameter
1.6. Set reject_to_small parameter
1.7. Set sst_flag parameter
1.8. sstCheckMin usage
1.5. Set reject_to_small parameter
1.6. Set sst_flag parameter
1.7. sstCheckMin usage

Chapter 1. Admin Guide

Expand All @@ -73,8 +69,7 @@ Chapter 1. Admin Guide
The sst module uses the dialog module to be notified of any new
or updated dialogs. It will then look for and extract the
session-expire: header value (if there is one) and override the
dialog expire timer value for the current context dialog by
setting the avp value.
dialog expire timer value for the current context dialog.

You flag any call setup INVITE that you want to cause a timed
session to be established. This will cause OpenSIPS to request
Expand Down Expand Up @@ -197,25 +192,7 @@ modparam("sst", "min_se", 2400)
modparam("sst", "sst_interval", 2400)
...

1.4.4. timeout_avp (string)

This parameter MUST be set to the same value as the dialog
parameter of the same name. If this parameter is NOT set, the
sst module will not do anything!

This is how the sst module knows which avp in the dialog module
to change with the new expire value.

Default value is “NULL!” it is not set by default.

Example 1.5. Set timeout_avp parameter
...
modparam("dialog", "timeout_avp", "$avp(10)")
# Set the sst modules timeout_avp to be the same value
modparam("sst", "timeout_avp", "$avp(10)")
...

1.4.5. reject_to_small (integer)
1.4.4. reject_to_small (integer)

In the initial INVITE if the UAC has requested a
Session-Expire: and it's value is smaller then our local
Expand All @@ -230,12 +207,12 @@ modparam("sst", "timeout_avp", "$avp(10)")

Default value is “1” (true/on).

Example 1.6. Set reject_to_small parameter
Example 1.5. Set reject_to_small parameter
...
modparam("sst", "reject_to_small", 0)
...

1.4.6. sst_flag (string/integer)
1.4.5. sst_flag (string/integer)

Keeping with OpenSIPS, the module will not do anything to any
message unless instructed to do so via the opensips.cfg script.
Expand All @@ -256,7 +233,7 @@ modparam("sst", "reject_to_small", 0)

Default value is “Not set!”.

Example 1.7. Set sst_flag parameter
Example 1.6. Set sst_flag parameter
...
modparam("sst", "sst_flag", "SST_FLAG")
...
Expand Down Expand Up @@ -287,13 +264,10 @@ route {
* min_allowed - The value to compare the MIN_SE header value
to.

Example 1.8. sstCheckMin usage
Example 1.7. sstCheckMin usage

...
modparam("dialog", "timeout_avp", "$avp(4242)")
...
modparam("sst", "sst_flag", 6)
modparam("sst", "timeout_avp", "$avp(4242)")
modparam("sst", "min_se", 2400) # Must be >= 90
...

Expand Down Expand Up @@ -331,7 +305,3 @@ route {
1.6.1. expired_sst

Number of dialogs which got expired session timer.

1.7. Installation and Running

just load the module and remember to set the timeout_avp value.
35 changes: 1 addition & 34 deletions modules/sst/doc/sst_admin.xml
Expand Up @@ -27,7 +27,7 @@
any new or updated dialogs. It will then look for and extract
the session-expire: header value (if there is one) and
override the dialog expire timer value for the current context
dialog by setting the avp value.</para>
dialog.</para>

<para>You flag any call setup INVITE that you want to cause a
timed session to be established. This will cause OpenSIPS to
Expand Down Expand Up @@ -211,32 +211,6 @@ modparam("sst", "sst_interval", 2400)
</example>
</section>

<section>
<title><varname>timeout_avp</varname> (string)</title>

<para>This parameter MUST be set to the same value as the
dialog parameter of the same name. If this parameter is
NOT set, the sst module will not do anything!</para>

<para>This is how the sst module knows which avp in the
dialog module to change with the new expire value.</para>

<para>
<emphasis>
Default value is <quote>NULL!</quote> it is not set by default.
</emphasis>
</para>
<example>
<title>Set <varname>timeout_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("dialog", "timeout_avp", "$avp(10)")
# Set the sst modules timeout_avp to be the same value
modparam("sst", "timeout_avp", "$avp(10)")
...
</programlisting>
</example>
</section>
<section>
<title><varname>reject_to_small</varname> (integer)</title>

Expand Down Expand Up @@ -344,11 +318,8 @@ route {
<title><function>sstCheckMin</function> usage</title>
<programlisting format="linespecific">

...
modparam("dialog", "timeout_avp", "$avp(4242)")
...
modparam("sst", "sst_flag", 6)
modparam("sst", "timeout_avp", "$avp(4242)")
modparam("sst", "min_se", 2400) # Must be >= 90
...

Expand Down Expand Up @@ -394,9 +365,5 @@ route {
</section>
</section>

<section>
<title>Installation and Running</title>
<para>just load the module and remember to set the timeout_avp value.</para>
</section>
</chapter>

25 changes: 1 addition & 24 deletions modules/sst/sst.c
Expand Up @@ -53,15 +53,6 @@ struct sig_binds sigb;
int sst_enable_stats = 1;
stat_var *expired_sst = 0;

/*
* The name of the AVP the dialog module will use to hold the timeout
* value so we can set the AVP in the dialog callbacks so the dialog
* code will set the dialog lifetime when it returns from the INVITE
* and IN_ROUTE callbacks.
*/
pv_spec_t timeout_avp;
static char* timeout_spec = 0; /* Place holder for the passed in name */

/*
* The default or script parameter for the requested MIN-SE: value for
* this proxy. (in seconds) If the passed in value is 0, then this
Expand Down Expand Up @@ -107,7 +98,6 @@ static cmd_export_t cmds[]={
static param_export_t mod_params[]={
{ "enable_stats", INT_PARAM, &sst_enable_stats },
{ "min_se", INT_PARAM, &sst_minSE },
{ "timeout_avp", STR_PARAM, &timeout_spec },
{ "reject_to_small", INT_PARAM, &sst_reject },
{ "sst_flag", STR_PARAM, &sst_flag_str },
{ "sst_flag", INT_PARAM, &sst_flag },
Expand Down Expand Up @@ -151,7 +141,6 @@ struct module_exports exports= {
*/
static int mod_init(void)
{
str s;
LM_INFO("SIP Session Timer module - initializing\n");
/*
* if statistics are disabled, prevent their registration to core.
Expand All @@ -173,17 +162,6 @@ static int mod_init(void)
return -1;
}

if (timeout_spec != NULL) {
LM_DBG("Dialog AVP is %s", timeout_spec);
s.s = timeout_spec; s.len = strlen(s.s);
if (pv_parse_spec(&s, &timeout_avp)==0
&& (timeout_avp.type != PVT_AVP)){
LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n",
timeout_spec);
return -1;
}
}

/* load SIGNALING API */
if(load_sig_api(&sigb)< 0) {
LM_ERR("can't load signaling functions\n");
Expand All @@ -193,8 +171,7 @@ static int mod_init(void)
/*
* Init the handlers
*/
sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE,
sst_flag, sst_reject,sst_interval);
sst_handler_init(sst_minSE, sst_flag, sst_reject,sst_interval);

/*
* Register the main (static) dialog call back.
Expand Down

0 comments on commit a65eca9

Please sign in to comment.