1
/* $Id: sip_timer.h 2859 2009-08-11 16:26:20Z nanang $ */
3
* Copyright (C) 2009 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Additional permission under GNU GPL version 3 section 7:
21
* If you modify this program, or any covered work, by linking or
22
* combining it with the OpenSSL project's OpenSSL library (or a
23
* modified version of that library), containing parts covered by the
24
* terms of the OpenSSL or SSLeay licenses, Teluu Inc. (http://www.teluu.com)
25
* grants you additional permission to convey the resulting work.
26
* Corresponding Source for a non-source form of such a combination
27
* shall include the source code for the parts of OpenSSL used as well
28
* as that of the covered work.
30
#ifndef __PJSIP_TIMER_H__
31
#define __PJSIP_TIMER_H__
36
* @brief SIP Session Timers support (RFC 4028 - Session Timer in SIP)
39
#include <pjsip-ua/sip_inv.h>
40
#include <pjsip/sip_msg.h>
43
* @defgroup PJSIP_TIMER SIP Session Timers support (RFC 4028 - Session Timers in SIP)
44
* @ingroup PJSIP_HIGH_UA
45
* @brief SIP Session Timers support (RFC 4028 - Session Timers in SIP)
48
* \section PJSIP_TIMER_REFERENCE References
51
* - <A HREF="http://www.ietf.org/rfc/rfc4028.txt">RFC 4028: Session Timers
52
* in the Session Initiation Protocol (SIP)</A>
58
* Opaque declaration of Session Timers.
60
typedef struct pjsip_timer pjsip_timer;
64
* This structure describes Session Timers settings in an invite session.
66
typedef struct pjsip_timer_setting
69
* Specify minimum session expiration period, in seconds. Must not be
70
* lower than 90. Default is 90.
75
* Specify session expiration period, in seconds. Must not be lower than
76
* #min_se. Default is 1800.
78
unsigned sess_expires;
80
} pjsip_timer_setting;
84
* SIP Session-Expires header (RFC 4028).
86
typedef struct pjsip_sess_expires_hdr
88
/** Standard header field. */
89
PJSIP_DECL_HDR_MEMBER(struct pjsip_sess_expires_hdr);
91
/** Session expiration period */
92
unsigned sess_expires;
97
/** Other parameters */
98
pjsip_param other_param;
100
} pjsip_sess_expires_hdr;
104
* SIP Min-SE header (RFC 4028).
106
typedef struct pjsip_min_se_hdr
108
/** Standard header field. */
109
PJSIP_DECL_HDR_MEMBER(struct pjsip_min_se_hdr);
111
/** Minimum session expiration period */
114
/** Other parameters */
115
pjsip_param other_param;
122
* Initialize Session Timers module. This function must be called once during
123
* application initialization, to register this module to SIP endpoint.
125
* @param endpt The SIP endpoint instance.
127
* @return PJ_SUCCESS if module is successfully initialized.
129
PJ_DECL(pj_status_t) pjsip_timer_init_module(pjsip_endpoint *endpt);
133
* Initialize Session Timers setting with default values.
135
* @param setting Session Timers setting to be initialized.
137
* @return PJ_SUCCESS on successful.
139
PJ_DECL(pj_status_t) pjsip_timer_setting_default(pjsip_timer_setting *setting);
143
* Initialize Session Timers for an invite session. This function should be
144
* called by application to apply Session Timers setting, otherwise invite
145
* session will apply default setting to the Session Timers.
147
* @param inv The invite session.
148
* @param setting Session Timers setting, see @pjsip_timer_setting.
149
* If setting is NULL, default setting will be applied.
151
* @return PJ_SUCCESS on successful.
153
PJ_DECL(pj_status_t) pjsip_timer_init_session(
154
pjsip_inv_session *inv,
155
const pjsip_timer_setting *setting);
159
* Create Session-Expires header.
161
* @param pool Pool to allocate the header instance from.
163
* @return An empty Session-Expires header instance.
165
PJ_DECL(pjsip_sess_expires_hdr*) pjsip_sess_expires_hdr_create(
170
* Create Min-SE header.
172
* @param pool Pool to allocate the header instance from.
174
* @return An empty Min-SE header instance.
176
PJ_DECL(pjsip_min_se_hdr*) pjsip_min_se_hdr_create(pj_pool_t *pool);
180
* Update outgoing request to insert Session Timers headers and also
181
* signal Session Timers capability in Supported and/or Require headers.
183
* This function will be called internally by the invite session if it
184
* detects that the session needs Session Timers support.
186
* @param inv The invite session.
187
* @param tdata Outgoing INVITE or UPDATE request.
189
* @return PJ_SUCCESS on successful.
191
PJ_DECL(pj_status_t) pjsip_timer_update_req(pjsip_inv_session *inv,
192
pjsip_tx_data *tdata);
196
* Process Session Timers headers in incoming response, this function
197
* will only process incoming response with status code 422 (Session
198
* Interval Too Small) or 2xx (final response).
200
* This function will be called internally by the invite session if it
201
* detects that the session needs Session Timers support.
203
* @param inv The invite session.
204
* @param rdata Incoming response data.
205
* @param st_code Output buffer to store corresponding SIP status code
206
* when function returning non-PJ_SUCCESS.
208
* @return PJ_SUCCESS on successful.
210
PJ_DECL(pj_status_t) pjsip_timer_process_resp(pjsip_inv_session *inv,
211
const pjsip_rx_data *rdata,
212
pjsip_status_code *st_code);
216
* Process Session Timers headers in incoming request, this function
217
* will only process incoming INVITE and UPDATE request.
219
* This function will be called internally by the invite session if it
220
* detects that the session needs Session Timers support.
222
* @param inv The invite session.
223
* @param rdata Incoming INVITE or UPDATE request.
224
* @param st_code Output buffer to store corresponding SIP status code
225
* when function returning non-PJ_SUCCESS.
227
* @return PJ_SUCCESS on successful.
229
PJ_DECL(pj_status_t) pjsip_timer_process_req(pjsip_inv_session *inv,
230
const pjsip_rx_data *rdata,
231
pjsip_status_code *st_code);
235
* Update outgoing response to insert Session Timers headers and also
236
* signal Session Timers capability in Supported and/or Require headers.
237
* This function will only update outgoing response with status code
238
* 422 (Session Interval Too Small) or 2xx (final response).
240
* This function will be called internally by the invite session if it
241
* detects that the session needs Session Timers support.
243
* @param inv The invite session.
244
* @param tdata Outgoing 422/2xx response.
246
* @return PJ_SUCCESS on successful.
248
PJ_DECL(pj_status_t) pjsip_timer_update_resp(pjsip_inv_session *inv,
249
pjsip_tx_data *tdata);
252
* End Session Timers in an invite session.
254
* This function will be called internally by the invite session if it
255
* detects that the session needs Session Timers support.
257
* @param inv The invite session.
259
* @return PJ_SUCCESS on successful.
261
PJ_DECL(pj_status_t) pjsip_timer_end_session(pjsip_inv_session *inv);
273
#endif /* __PJSIP_TIMER_H__ */