1
/* $Id: sip_xfer.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 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
#ifndef __PJSIP_XFER_H__
21
#define __PJSIP_XFER_H__
27
* @brief SIP Transfer (REFER, RFC 3515)
29
#include <pjsip-simple/evsub.h>
30
#include <pjsip/sip_msg.h>
33
* @defgroup PJSUA_XFER SIP REFER (RFC 3515) for Call Transfer etc.
34
* @ingroup PJSIP_HIGH_UA
35
* @brief SIP REFER dialog usage (call transfer, etc.)
38
* This describes a generic handling of SIP REFER request. The SIP REFER
39
* request is described in RFC 3515, and commonly used to perform call
40
* transfer functionality. Other types of SIP REFER usages are described
41
* in draft-worley-sip-many-refers-00 draft, for example:
42
* - Remote Dial: where UAC sends REFER to instruct REFER recipient to
43
* initiate an INVITE session to some target.
45
* A REFER request can be sent inside or outside existing dialog context,
46
* although for call transfer case, it is more common to send REFER inside
47
* existing INVITE session context. PJSIP supports both sending REFER request
48
* inside or outside dialog context.
50
* The REFER framework uses @ref PJSIP_EVENT_NOT to manage the event
51
* subscription created by the REFER request. Because of this, application
52
* must link with <b>pjsip-ua</b> AND <b>pjsip-simple</b> static libraries
53
* to use REFER functionality.
56
* - <A HREF="http://www.ietf.org/rfc/rfc3515.txt">RFC 3515: The Session
57
* Initiation Protocol (SIP) Refer Method</A>
58
* - @ref PJSIP_EVENT_NOT
65
/** Declaration for REFER method constant. */
66
PJ_DECL_DATA(const pjsip_method) pjsip_refer_method;
68
/** Get REFER method constant */
69
PJ_DECL(const pjsip_method*) pjsip_get_refer_method(void);
73
* Initialize the REFER subsystem.
74
* This currently does very little (only register REFER as supported method).
76
PJ_DECL(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt);
81
* Create transferer (sender of REFER request).
83
* @param dlg The underlying dialog to use.
84
* @param user_cb Pointer to callbacks to receive presence subscription
86
* @param p_evsub Pointer to receive the presence subscription
89
* @return PJ_SUCCESS on success.
91
PJ_DECL(pj_status_t) pjsip_xfer_create_uac( pjsip_dialog *dlg,
92
const pjsip_evsub_user *user_cb,
93
pjsip_evsub **p_evsub );
97
* Create transferee (receiver of REFER request).
99
* @param dlg The underlying dialog to use.
100
* @param user_cb Pointer to callbacks to receive presence subscription
102
* @param rdata The incoming SUBSCRIBE request that creates the event
104
* @param p_evsub Pointer to receive the presence subscription
107
* @return PJ_SUCCESS on success.
109
PJ_DECL(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg,
110
const pjsip_evsub_user *user_cb,
111
pjsip_rx_data *rdata,
112
pjsip_evsub **p_evsub );
115
* Call this function to create request to initiate REFER subscription,
116
* to refresh subscription, or to unsubscribe. For request other than
117
* the initial REFER request, "refer_to_uri" argument may be NULL.
119
* @param sub Client subscription instance.
120
* @param refer_to_uri URI to be put to the Refer-To header. This argument
121
* may be NULL for subsequent REFER requests.
122
* @param p_tdata Pointer to receive the request.
124
* @return PJ_SUCCESS on success.
126
PJ_DECL(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub,
127
const pj_str_t *refer_to_uri,
128
pjsip_tx_data **p_tdata);
132
* Accept the incoming REFER request by sending 2xx response.
134
* @param sub Server subscription instance.
135
* @param rdata The incoming subscription request message.
136
* @param st_code Status code, which MUST be 2xx.
137
* @param hdr_list Optional list of headers to be added in the response.
139
* @return PJ_SUCCESS on success.
141
PJ_DECL(pj_status_t) pjsip_xfer_accept( pjsip_evsub *sub,
142
pjsip_rx_data *rdata,
144
const pjsip_hdr *hdr_list );
148
* For notifier, create NOTIFY request to subscriber, and set the state
149
* of the subscription.
151
* @param sub The server subscription (notifier) instance.
152
* @param state New state to set.
153
* @param xfer_st_code The call status code to be reported with the NOTIFY
155
* @param xfer_st_text Optional call status text to be reported with the
156
* NOTIFY request. If the value is NULL, default
157
* status text will be used.
158
* @param p_tdata Pointer to receive the request.
160
* @return PJ_SUCCESS on success.
162
PJ_DECL(pj_status_t) pjsip_xfer_notify( pjsip_evsub *sub,
163
pjsip_evsub_state state,
165
const pj_str_t *xfer_st_text,
166
pjsip_tx_data **p_tdata);
170
* Create NOTIFY request to reflect current subscription status. Application
171
* can only call this function after it has sent NOTIFY before.
172
* This will also re-send the last "message/sipfrag" body that was sent
173
* in the previous NOTIFY.
175
* @param sub Server subscription object.
176
* @param p_tdata Pointer to receive request.
178
* @return PJ_SUCCESS on success.
180
PJ_DECL(pj_status_t) pjsip_xfer_current_notify( pjsip_evsub *sub,
181
pjsip_tx_data **p_tdata );
186
* Send request message that was previously created with initiate(), notify(),
187
* or current_notify(). Application may also send request created with other
188
* functions, e.g. authentication. But the request MUST be either request
189
* that creates/refresh subscription or NOTIFY request.
192
* @param sub The event subscription object.
193
* @param tdata Request message to be send.
195
* @return PJ_SUCCESS on success.
197
PJ_DECL(pj_status_t) pjsip_xfer_send_request( pjsip_evsub *sub,
198
pjsip_tx_data *tdata);
207
#endif /* __PJSIP_XFER_H__ */