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"
Go to the source code of this file.
Definition in file sst_handlers.c.
| static int append_header | ( | struct sip_msg * | msg, | |
| const char * | header | |||
| ) | [static] |
| msg | The message to append the header text to. | |
| header | The header text to append. |
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().


| static int parse_msg_for_sst_info | ( | struct sip_msg * | msg, | |
| sst_msg_info_t * | minfo | |||
| ) | [static] |
| msg | The current message to parse. | |
| minfo | The SST information found in the message. |
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().


| static int remove_header | ( | struct sip_msg * | msg, | |
| const char * | header | |||
| ) | [static] |
| msg | The message to look for the header to remove. | |
| header | The header name: text. |
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().

| static int send_reject | ( | struct sip_msg * | msg, | |
| unsigned int | min_se | |||
| ) | [static] |
| msg | The message to opperate on. | |
| min_se | The Min-SE: value to use in the heaader. |
Definition at line 915 of file sst_handlers.c.
References _str::len, _str::s, and send_response().
Referenced by sst_dialog_created_CB().


| 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.
| 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) |
Definition at line 706 of file sst_handlers.c.
References add_lump_rpl().
Referenced by send_reject(), and sst_check_min().


| static int set_timeout_avp | ( | struct sip_msg * | msg, | |
| unsigned int | value | |||
| ) | [static] |
| msg | The current message to bind the AVP to. | |
| value | The value you want to set the AVP to. |
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().

| static void setup_dialog_callbacks | ( | struct dlg_cell * | did, | |
| sst_info_t * | info | |||
| ) | [static] |
| 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().


| 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.
| 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. |
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.

| 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:
| 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().


| 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)
| 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().


| 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.
| 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().


| 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.
| 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().

| 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.
| 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().

Most importantly the register_dlgcb function.
Definition at line 53 of file qos.c.
Referenced by setup_dialog_callbacks().
1.7.1