1
/* $Id: sip_timer.h 4715 2014-01-24 09:32:27Z riza $ */
3
* Copyright (C) 2009-2011 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
#ifndef __PJSIP_TIMER_H__
20
#define __PJSIP_TIMER_H__
25
* @brief SIP Session Timers support (RFC 4028 - Session Timer in SIP)
28
#include <pjsip-ua/sip_inv.h>
29
#include <pjsip/sip_msg.h>
32
* @defgroup PJSIP_TIMER SIP Session Timers support (RFC 4028 - Session Timers in SIP)
33
* @ingroup PJSIP_HIGH_UA
34
* @brief SIP Session Timers support (RFC 4028 - Session Timers in SIP)
37
* \section PJSIP_TIMER_REFERENCE References
40
* - <A HREF="http://www.ietf.org/rfc/rfc4028.txt">RFC 4028: Session Timers
41
* in the Session Initiation Protocol (SIP)</A>
47
* Opaque declaration of Session Timers.
49
typedef struct pjsip_timer pjsip_timer;
53
* This structure describes Session Timers settings in an invite session.
55
typedef struct pjsip_timer_setting
58
* Specify minimum session expiration period, in seconds. Must not be
59
* lower than 90. Default is 90.
64
* Specify session expiration period, in seconds. Must not be lower than
65
* #min_se. Default is 1800.
67
unsigned sess_expires;
69
} pjsip_timer_setting;
73
* SIP Session-Expires header (RFC 4028).
75
typedef struct pjsip_sess_expires_hdr
77
/** Standard header field. */
78
PJSIP_DECL_HDR_MEMBER(struct pjsip_sess_expires_hdr);
80
/** Session expiration period */
81
unsigned sess_expires;
86
/** Other parameters */
87
pjsip_param other_param;
89
} pjsip_sess_expires_hdr;
93
* SIP Min-SE header (RFC 4028).
95
typedef struct pjsip_min_se_hdr
97
/** Standard header field. */
98
PJSIP_DECL_HDR_MEMBER(struct pjsip_min_se_hdr);
100
/** Minimum session expiration period */
103
/** Other parameters */
104
pjsip_param other_param;
111
* Initialize Session Timers module. This function must be called once during
112
* application initialization, to register this module to SIP endpoint.
114
* @param endpt The SIP endpoint instance.
116
* @return PJ_SUCCESS if module is successfully initialized.
118
PJ_DECL(pj_status_t) pjsip_timer_init_module(pjsip_endpoint *endpt);
122
* Initialize Session Timers setting with default values.
124
* @param setting Session Timers setting to be initialized.
126
* @return PJ_SUCCESS on successful.
128
PJ_DECL(pj_status_t) pjsip_timer_setting_default(pjsip_timer_setting *setting);
132
* Initialize Session Timers for an invite session. This function should be
133
* called by application to apply Session Timers setting, otherwise invite
134
* session will apply default setting to the Session Timers.
136
* @param inv The invite session.
137
* @param setting Session Timers setting, see @pjsip_timer_setting.
138
* If setting is NULL, default setting will be applied.
140
* @return PJ_SUCCESS on successful.
142
PJ_DECL(pj_status_t) pjsip_timer_init_session(
143
pjsip_inv_session *inv,
144
const pjsip_timer_setting *setting);
148
* Create Session-Expires header.
150
* @param pool Pool to allocate the header instance from.
152
* @return An empty Session-Expires header instance.
154
PJ_DECL(pjsip_sess_expires_hdr*) pjsip_sess_expires_hdr_create(
159
* Create Min-SE header.
161
* @param pool Pool to allocate the header instance from.
163
* @return An empty Min-SE header instance.
165
PJ_DECL(pjsip_min_se_hdr*) pjsip_min_se_hdr_create(pj_pool_t *pool);
169
* Update outgoing request to insert Session Timers headers and also
170
* signal Session Timers capability in Supported and/or Require headers.
172
* This function will be called internally by the invite session if it
173
* detects that the session needs Session Timers support.
175
* @param inv The invite session.
176
* @param tdata Outgoing INVITE or UPDATE request.
178
* @return PJ_SUCCESS on successful.
180
PJ_DECL(pj_status_t) pjsip_timer_update_req(pjsip_inv_session *inv,
181
pjsip_tx_data *tdata);
185
* Process Session Timers headers in incoming response, this function
186
* will only process incoming response with status code 422 (Session
187
* Interval Too Small) or 2xx (final response).
189
* This function will be called internally by the invite session if it
190
* detects that the session needs Session Timers support.
192
* @param inv The invite session.
193
* @param rdata Incoming response data.
194
* @param st_code Output buffer to store corresponding SIP status code
195
* when function returning non-PJ_SUCCESS.
197
* @return PJ_SUCCESS on successful.
199
PJ_DECL(pj_status_t) pjsip_timer_process_resp(pjsip_inv_session *inv,
200
const pjsip_rx_data *rdata,
201
pjsip_status_code *st_code);
204
* Process Session Timers refresh error, this function will process
205
* error from refresh request. The error will be handle according the
206
* error code, i.e : BYE will be sent after error 503 (Transport Error).
208
* @param inv The invite session.
209
* @param event The event that trigger the error.
211
* @return PJ_SUCCESS on successful.
213
PJ_DECL(pj_status_t) pjsip_timer_handle_refresh_error(
214
pjsip_inv_session *inv,
218
* Process Session Timers headers in incoming request, this function
219
* will only process incoming INVITE and UPDATE request.
221
* This function will be called internally by the invite session if it
222
* detects that the session needs Session Timers support.
224
* @param inv The invite session.
225
* @param rdata Incoming INVITE or UPDATE request.
226
* @param st_code Output buffer to store corresponding SIP status code
227
* when function returning non-PJ_SUCCESS.
229
* @return PJ_SUCCESS on successful.
231
PJ_DECL(pj_status_t) pjsip_timer_process_req(pjsip_inv_session *inv,
232
const pjsip_rx_data *rdata,
233
pjsip_status_code *st_code);
237
* Update outgoing response to insert Session Timers headers and also
238
* signal Session Timers capability in Supported and/or Require headers.
239
* This function will only update outgoing response with status code
240
* 422 (Session Interval Too Small) or 2xx (final response).
242
* This function will be called internally by the invite session if it
243
* detects that the session needs Session Timers support.
245
* @param inv The invite session.
246
* @param tdata Outgoing 422/2xx response.
248
* @return PJ_SUCCESS on successful.
250
PJ_DECL(pj_status_t) pjsip_timer_update_resp(pjsip_inv_session *inv,
251
pjsip_tx_data *tdata);
254
* End Session Timers in an invite session.
256
* This function will be called internally by the invite session if it
257
* detects that the session needs Session Timers support.
259
* @param inv The invite session.
261
* @return PJ_SUCCESS on successful.
263
PJ_DECL(pj_status_t) pjsip_timer_end_session(pjsip_inv_session *inv);
275
#endif /* __PJSIP_TIMER_H__ */