1
/* $Id: sip_100rel.h 2394 2008-12-23 17:27:53Z bennylp $ */
3
* Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
* Additional permission under GNU GPL version 3 section 7:
22
* If you modify this program, or any covered work, by linking or
23
* combining it with the OpenSSL project's OpenSSL library (or a
24
* modified version of that library), containing parts covered by the
25
* terms of the OpenSSL or SSLeay licenses, Teluu Inc. (http://www.teluu.com)
26
* grants you additional permission to convey the resulting work.
27
* Corresponding Source for a non-source form of such a combination
28
* shall include the source code for the parts of OpenSSL used as well
29
* as that of the covered work.
31
#ifndef __SIP_100REL_H__
32
#define __SIP_100REL_H__
36
* @brief PRACK (Reliability of Provisional Responses)
40
#include <pjsip-ua/sip_inv.h>
44
* @defgroup PJSIP_100REL 100rel/PRACK - Reliability of Provisional Responses
45
* @ingroup PJSIP_HIGH_UA
46
* @brief PRACK - Reliability of Provisional Responses
49
* This module provides management of Reliability of Provisional Responses
50
* (\a 100rel and \a PRACK), as described in RFC 3262.
52
* Other than the #pjsip_100rel_init_module() function, the 100rel API
53
* exported by this module are not intended to be used by application, but
54
* rather they will be invoked by the \ref PJSIP_INV.
56
* \section pjsip_100rel_using Using Reliable Provisional Response
58
* \subsection pjsip_100rel_init Initializing 100rel Module
60
* Application must explicitly initialize 100rel module by calling
61
* #pjsip_100rel_init_module() in application initialization function.
63
* Once the 100rel module is initialized, it will register \a PRACK method
64
* in \a Allow header, and \a 100rel tag in \a Supported header.
66
* \subsection pjsip_100rel_sess Using 100rel in a Session
68
* For UAC, \a 100rel support will be enabled in the session if \a 100rel
69
* support is enabled in the library (default is yes).
70
* Outgoing INVITE request will include \a 100rel tag in \a Supported
71
* header and \a PRACK method in \a Allow header. When callee endpoint
72
* sends reliable provisional responses, the UAC will automatically send
73
* \a PRACK request to acknowledge the response. If callee endpoint doesn't
74
* send reliable provisional response, the response will be handled using
75
* normal, non-100rel procedure (that is, \a PRACK will not be sent).
77
* If the UAC wants to <b>mandate</b> \a 100rel support, it can specify
78
* #PJSIP_INV_REQUIRE_100REL in the \a options argument when calling
79
* #pjsip_inv_create_uac(). In this case, PJSIP will add \a 100rel tag
80
* in the \a Require header of the outgoing INVITE request.
82
* For UAS, if it wants to support \a 100rel but not to mandate it,
83
* it must specify #PJSIP_INV_SUPPORT_100REL flag in the \a options
84
* argument when calling #pjsip_inv_verify_request(), and pass the same
85
* \a options variable when calling #pjsip_inv_verify_request. If UAC had
86
* specified \a 100rel in it's list of extensions in \a Require header,
87
* the UAS will send provisional responses reliably. If UAC only listed
88
* \a 100rel in its \a Supported header but not in \a Require header,
89
* or if UAC does not list \a 100rel support at all, the UAS WILL NOT
90
* send provisional responses reliably.
91
* The snippet below can be used to accomplish this task:
96
options |= PJSIP_INV_SUPPORT_100REL;
98
status = pjsip_inv_verify_request(rdata, &options, answer, NULL,
100
if (status != PJ_SUCCESS) {
101
// INVITE request cannot be handled.
102
// Reject the request with the response in resp.
107
// Create UAS dialog, populate Contact header, etc.
110
// Create UAS invite session
111
status = pjsip_inv_create_uas( dlg, rdata, answer, options, &inv);
117
* For another requirement, if UAS wants to <b>mandate</b> \a 100rel support,
118
* it can specify #PJSIP_INV_REQUIRE_100REL flag when calling
119
* #pjsip_inv_verify_request(), and pass the \a options when calling
120
* #pjsip_inv_verify_request. In this case,
121
* \a 100rel extension will be used if UAC specifies \a 100rel in its
122
* \a Supported header. If UAC does not list \a 100rel in \a Supported header,
123
* the incoming INVITE request will be rejected with 421 (Extension Required)
124
* response. For the sample code, it should be identical to the snippet
125
* above, except that application must specify #PJSIP_INV_REQUIRE_100REL
126
* flag in the \a options instead of #PJSIP_INV_SUPPORT_100REL.
128
* For yet another requirement, if UAS <b>does not</b> want to support
129
* \a 100rel extension, it can reject incoming INVITE request with
130
* 420 (Bad Extension) response whenever incoming INVITE request has
131
* \a 100rel tag in its \a Require header. This can be done by specifying
132
* zero as the \a options when calling #pjsip_inv_verify_request().
139
* PRACK method constant.
140
* @see pjsip_get_prack_method()
142
PJ_DECL_DATA(const pjsip_method) pjsip_prack_method;
146
* Get #pjsip_invite_method constant.
148
PJ_DECL(const pjsip_method*) pjsip_get_prack_method(void);
152
* Initialize 100rel module. This function must be called once during
153
* application initialization, to register 100rel module to SIP endpoint.
155
* @param endpt The SIP endpoint instance.
157
* @return PJ_SUCCESS if module is successfully initialized.
159
PJ_DECL(pj_status_t) pjsip_100rel_init_module(pjsip_endpoint *endpt);
163
* Add 100rel support to the specified invite session. This function will
164
* be called internally by the invite session if it detects that the
165
* session needs 100rel support.
167
* @param inv The invite session.
169
* @return PJ_SUCCESS on successful.
171
PJ_DECL(pj_status_t) pjsip_100rel_attach(pjsip_inv_session *inv);
175
* Check if incoming response has reliable provisional response feature.
177
* @param rdata Receive data buffer containing the response.
179
* @return PJ_TRUE if the provisional response is reliable.
181
PJ_DECL(pj_bool_t) pjsip_100rel_is_reliable(pjsip_rx_data *rdata);
185
* Create PRACK request for the incoming reliable provisional response.
186
* Note that PRACK request MUST be sent using #pjsip_100rel_send_prack().
188
* @param inv The invite session.
189
* @param rdata The incoming reliable provisional response.
190
* @param p_tdata Upon return, it will be initialized with the
193
* @return PJ_SUCCESS on successful.
195
PJ_DECL(pj_status_t) pjsip_100rel_create_prack(pjsip_inv_session *inv,
196
pjsip_rx_data *rdata,
197
pjsip_tx_data **p_tdata);
200
* Send PRACK request.
202
* @param inv The invite session.
203
* @param tdata The PRACK request.
205
* @return PJ_SUCCESS on successful.
207
PJ_DECL(pj_status_t) pjsip_100rel_send_prack(pjsip_inv_session *inv,
208
pjsip_tx_data *tdata);
212
* Handle incoming PRACK request.
214
* @param inv The invite session.
215
* @param rdata Incoming PRACK request.
217
* @return PJ_SUCCESS on successful.
219
PJ_DECL(pj_status_t) pjsip_100rel_on_rx_prack(pjsip_inv_session *inv,
220
pjsip_rx_data *rdata);
224
* Transmit INVITE response (provisional or final) reliably according to
225
* 100rel specification. The 100rel module will take care of retransmitting
226
* or enqueueing the response according to the current state of the
227
* reliable response processing. This function will be called internally
230
* @param inv The invite session.
231
* @param tdata The INVITE response.
233
* @return PJ_SUCCESS on successful.
235
PJ_DECL(pj_status_t) pjsip_100rel_tx_response(pjsip_inv_session *inv,
236
pjsip_tx_data *tdata);
240
* Notify 100rel module that the invite session has been disconnected.
242
* @param inv The invite session.
244
* @return PJ_SUCCESS on successful.
246
PJ_DECL(pj_status_t) pjsip_100rel_end_session(pjsip_inv_session *inv);
256
#endif /* __SIP_100REL_H__ */