Data Structures | Typedefs | Functions | Variables

sst_handlers.c File Reference

Functions for the SST moduleModule: SIP Session Timers module. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../../pvar.h"
#include "../../lib/kcore/parse_sst.h"
#include "../../lib/kcore/parse_supported.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "../../data_lump.h"
#include "../../data_lump_rpl.h"
#include "../../ut.h"
#include "../../lvalue.h"
#include "../../dprint.h"
#include "../../sr_module.h"
#include "../../modules/sl/sl.h"
#include "sst_handlers.h"
#include "sst_mi.h"
Include dependency graph for sst_handlers.c:

Go to the source code of this file.

Data Structures

Typedefs

Functions

Variables


Detailed Description

Definition in file sst_handlers.c.


Function Documentation

static int append_header ( struct sip_msg msg,
const char *  header 
) [static]
Parameters:
msg The message to append the header text to.
header The header text to append.
Returns:
0 on success, non-zero on failure.

Definition at line 739 of file sst_handlers.c.

References anchor_lump(), sip_msg::buf, HDR_EOH_F, and sip_msg::unparsed.

Referenced by sst_dialog_created_CB(), and sst_dialog_response_fwded_CB().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_msg_for_sst_info ( struct sip_msg msg,
sst_msg_info_t minfo 
) [static]
Parameters:
msg The current message to parse.
minfo The SST information found in the message.
Returns:
0 on success, -1 on a parsing error.

Definition at line 864 of file sst_handlers.c.

References parse_min_se(), parse_session_expires(), parse_supported(), and hdr_field::parsed.

Referenced by sst_dialog_created_CB(), sst_dialog_request_within_CB(), and sst_dialog_response_fwded_CB().

Here is the call graph for this function:

Here is the caller graph for this function:

static int remove_header ( struct sip_msg msg,
const char *  header 
) [static]
Parameters:
msg The message to look for the header to remove.
header The header name: text.
Returns:
0 if the header was not found, >0 is successful, -1 on an error.

Definition at line 780 of file sst_handlers.c.

References sip_msg::buf, HDR_EOH_F, sip_msg::headers, _str::len, hdr_field::len, hdr_field::name, hdr_field::next, and _str::s.

Referenced by sst_dialog_created_CB().

Here is the caller graph for this function:

static int send_reject ( struct sip_msg msg,
unsigned int  min_se 
) [static]
Parameters:
msg The message to opperate on.
min_se The Min-SE: value to use in the heaader.
Returns:
0 on success, -1 on error.

Definition at line 915 of file sst_handlers.c.

References _str::len, _str::s, and send_response().

Referenced by sst_dialog_created_CB().

Here is the call graph for this function:

Here is the caller graph for this function:

static int send_response ( struct sip_msg request,
int  code,
str reason,
char *  header,
int  header_len 
) [static]

If the header is not NULL (and header_len != 0) the add the header to the reply message.

Parameters:
request The SIP request message to build the reply from.
code The response code. i.e 200
reason The response reason. i.e. "OK"
header the header block to add to the reply.
header_len The length of the header block. (header)
Returns:
0 on success, none-zero on an error.

Definition at line 706 of file sst_handlers.c.

References add_lump_rpl().

Referenced by send_reject(), and sst_check_min().

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_timeout_avp ( struct sip_msg msg,
unsigned int  value 
) [static]
Parameters:
msg The current message to bind the AVP to.
value The value you want to set the AVP to.
Returns:
0 on success, -1 on an error.

Definition at line 819 of file sst_handlers.c.

References timeout_avp.

Referenced by sst_dialog_created_CB(), sst_dialog_request_within_CB(), and sst_dialog_response_fwded_CB().

Here is the caller graph for this function:

static void setup_dialog_callbacks ( struct dlg_cell did,
sst_info_t info 
) [static]
Parameters:
did The Dialog ID.
info The sst information.

Definition at line 937 of file sst_handlers.c.

References dlg_binds, sst_dialog_mi_context_CB(), sst_dialog_request_within_CB(), sst_dialog_response_fwded_CB(), and sst_dialog_terminate_CB().

Referenced by sst_dialog_created_CB().

Here is the call graph for this function:

Here is the caller graph for this function:

int sst_check_min ( struct sip_msg msg,
char *  flag,
char *  str2 
)

The script function.

Return 1 (true) if the MIN-SE: of the message is too small compared to the sst_min_se value. This will allow the script to reply to this INVITE with a "422 Session Timer Too Small" response. if sst_min_se was never set the recommended value of 1800 seconds will be used.

If the flag (str1) is set to 1, the 422 reply will be sent with the sst MIN_SE value in the header. If the flag is not set or is NULL, no reply is sent.

Parameters:
msg - The sip message from the script (INVITE only)
flag - Reply mode Flag. 0/NULL do not send reply, 1 send 422 reply if Session-Expires is to small with the MIN-SE header in the reply
str2 - Not used.
Returns:
1 if the MIN-SE is too small, -1 if it is OK, or It could not be checked.

NOTE: returning 0 == drop message, 1 == true, -1 == false in the script.

Definition at line 611 of file sst_handlers.c.

References sip_msg::first_line, _str::len, METHOD_INVITE, parse_min_se(), parse_session_expires(), _str::s, send_response(), and sst_min_se.

Here is the call graph for this function:

void sst_dialog_created_CB ( struct dlg_cell did,
int  type,
struct dlg_cb_params *  params 
)

The static (opening) callback function for all dialog creations.

We need to track the dialogs lifespan from this point forward until it is terminated with a BYE, CANCEL, etc. In the process, we will see if either or both ends of the conversation supports SIP Session Timers and setup the dialog timeout to expire at the session timer expire time. Each time the new re-INVITE is seen to update the SST, we will reset the life span of the dialog to match it.

This function will setup the other types of dialog callbacks required to track the lifespan of the dialog. It will also start the state tracking to figure out if and who supports SST.

As per RFC4028: Request handling:

  • The proxy may insert a SE header if none found.
  • The SE value can be anything >= Min-SE (if found)
  • The proxy MUST NOT add a refresher parameter to the SE.
  • If SE is already there, the Proxy can reduce its value but no lower then the Min-SE value if present.
  • If the SE value is >= Min-SE the proxy MUST NOT increase it!
  • If the SE value is < Min-SE (settable by the proxy) the proxy MUST increase the SE value to >= the new Min-SE.
  • The proxy MUST NOT insert or change the refresher parameter.
  • If the supported=timer is found, the proxy may reject the request with a 422 if the SE value is smaller then the local policy. The 422 MUST hold the proxies Min-SE value >= 90.
  • If support=timer is NOT indecated, the proxy can't reject with a 422 but can include/increase the MIN-SE: to be = to local policy. and increase the SE to match the new Min-SE value.
  • the proxy MUST NOT insert/change the Min-SE header if supported=timer is present. (DoS attacks)
Parameters:
did - The dialog ID
type - The trigger event type (CREATED)
params - The pointer to nothing. As we did not attach anything to this callback in the dialog module.

Definition at line 249 of file sst_handlers.c.

References append_header(), sip_msg::first_line, METHOD_INVITE, parse_msg_for_sst_info(), remove_header(), _str::s, send_reject(), set_timeout_avp(), setup_dialog_callbacks(), sst_flag, sst_min_se, and sst_reject.

Referenced by mod_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void sst_dialog_request_within_CB ( struct dlg_cell did,
int  type,
struct dlg_cb_params *  params 
) [static]

We are only interested in the INVITE or UPDATE if SST is supported and active for this dialog. In this case, we need to update the expire time for the dialog based on the Session-Expires: header in the reINVITE/UPDATE request.

When this callback returns control to the dialog module it WILL reset the timeout of the dialog. We need to make sure we set the AVP here or the dialog timeout will be reset to the DEFAULT value if this is a different transaction. (so the AVP value is gone)

Parameters:
did - The dialog structure. The pointer is used as an ID.
type - The reason for the callback. DLGCB_REQ_WITHIN
params - The sst information

Definition at line 428 of file sst_handlers.c.

References sip_msg::first_line, METHOD_INVITE, METHOD_PRACK, METHOD_UPDATE, parse_msg_for_sst_info(), and set_timeout_avp().

Referenced by setup_dialog_callbacks().

Here is the call graph for this function:

Here is the caller graph for this function:

static void sst_dialog_response_fwded_CB ( struct dlg_cell did,
int  type,
struct dlg_cb_params *  params 
) [static]

The callback is called just before the message is copied to pkg memory so it is still mutable.

Parameters:
did - The dialog structure. The pointer is used as an ID.
type - The reason for the callback. DLGCB_CONFIRMED
params - The sst information

Definition at line 496 of file sst_handlers.c.

References append_header(), sip_msg::first_line, get_cseq, METHOD_INVITE, METHOD_UPDATE, parse_msg_for_sst_info(), _str::s, and set_timeout_avp().

Referenced by setup_dialog_callbacks().

Here is the call graph for this function:

Here is the caller graph for this function:

static void sst_dialog_terminate_CB ( struct dlg_cell did,
int  type,
struct dlg_cb_params *  params 
) [static]

This callback is called when ever a dialog is terminated.

The cause of the termination can be normal, failed call, or expired. It is the expired dialog we are really interested in.

Parameters:
did - The Dialog ID / structure pointer. Used as an ID only.
type - The termination cause/reason.
params - The sst information

Definition at line 383 of file sst_handlers.c.

Referenced by setup_dialog_callbacks().

Here is the caller graph for this function:

void sst_handler_init ( pv_spec_t *  timeout_avp_p,
unsigned int  min_se,
int  flag,
unsigned int  reject 
)

The handlers initializer function.

This function is called when the module is loaded from the mod_init() function in sst.c to initialize the callback handlers and local variables.

Parameters:
timeout_avp_p - The pointer to the dialog modules timeout AVP.
min_se - The minimum session expire value allowed by this PROXY.
flag - sst flag
reject - reject state

Definition at line 199 of file sst_handlers.c.

References sst_flag, sst_min_se, sst_reject, and timeout_avp.

Referenced by mod_init().

Here is the caller graph for this function:


Variable Documentation

Most importantly the register_dlgcb function.

Definition at line 53 of file qos.c.

Referenced by setup_dialog_callbacks().