transaction.h 5.18 KB
Newer Older
1 2 3 4 5 6
/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  Belledonne Communications SARL

    This program is free software: you can redistribute it and/or modify
    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 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BELLE_SIP_TRANSACTION_H
#define BELLE_SIP_TRANSACTION_H


typedef enum belle_sip_transaction_state{
23
	BELLE_SIP_TRANSACTION_INIT,
24 25 26
	BELLE_SIP_TRANSACTION_CALLING,
	BELLE_SIP_TRANSACTION_COMPLETED,
	BELLE_SIP_TRANSACTION_CONFIRMED,
27
	BELLE_SIP_TRANSACTION_ACCEPTED, /*<for Invite transaction, introduced by RFC6026, fixing bugs in RFC3261*/
28 29 30 31 32
	BELLE_SIP_TRANSACTION_PROCEEDING,
	BELLE_SIP_TRANSACTION_TRYING,
	BELLE_SIP_TRANSACTION_TERMINATED
}belle_sip_transaction_state_t;

33
BELLE_SIP_BEGIN_DECLS
34

35 36
BELLESIP_EXPORT const char *belle_sip_transaction_state_to_string(const belle_sip_transaction_state_t state);
/*
Simon Morlat's avatar
Simon Morlat committed
37
 * Transient states are:
38 39 40 41 42 43 44 45 46
 * 	<br> BELLE_SIP_TRANSACTION_INIT,
 *	<br> BELLE_SIP_TRANSACTION_CALLING,
 *	<br> BELLE_SIP_TRANSACTION_PROCEEDING,
 *	<br> BELLE_SIP_TRANSACTION_TRYING,
 * @param state
 * @return 0 if not transient
 * */
BELLESIP_EXPORT int belle_sip_transaction_state_is_transient(const belle_sip_transaction_state_t state);

jehan's avatar
jehan committed
47

Sylvain Berfini's avatar
Sylvain Berfini committed
48 49
BELLESIP_EXPORT void *belle_sip_transaction_get_application_data(const belle_sip_transaction_t *t);
BELLESIP_EXPORT void belle_sip_transaction_set_application_data(belle_sip_transaction_t *t, void *data);
50
BELLESIP_EXPORT const char *belle_sip_transaction_get_branch_id(const belle_sip_transaction_t *t);
Sylvain Berfini's avatar
Sylvain Berfini committed
51
BELLESIP_EXPORT belle_sip_transaction_state_t belle_sip_transaction_get_state(const belle_sip_transaction_t *t);
52
BELLESIP_EXPORT const char *belle_sip_transaction_get_method(const belle_sip_transaction_t *t);
53
BELLESIP_EXPORT void belle_sip_transaction_terminate(belle_sip_transaction_t *t);
54
BELLESIP_EXPORT belle_sip_request_t *belle_sip_transaction_get_request(const belle_sip_transaction_t *t);
55
BELLESIP_EXPORT belle_sip_response_t *belle_sip_transaction_get_response(const belle_sip_transaction_t *t);
56
BELLESIP_EXPORT belle_sip_dialog_t*  belle_sip_transaction_get_dialog(const belle_sip_transaction_t *t);
57

58
BELLESIP_EXPORT void belle_sip_server_transaction_send_response(belle_sip_server_transaction_t *t, belle_sip_response_t *resp);
59

Sylvain Berfini's avatar
Sylvain Berfini committed
60
BELLESIP_EXPORT belle_sip_request_t * belle_sip_client_transaction_create_cancel(belle_sip_client_transaction_t *t);
61
BELLESIP_EXPORT int belle_sip_client_transaction_send_request(belle_sip_client_transaction_t *t);
62 63 64 65 66
/*
 * Same as #belle_sip_client_transaction_send_request but with a predefined route.
 * @param  t  belle_sip_client_transaction_t
 * @param outbound_proxy uri use to directly send the request, useful for outbound proxy.
 * */
67
BELLESIP_EXPORT int belle_sip_client_transaction_send_request_to(belle_sip_client_transaction_t *t,belle_sip_uri_t* outbound_proxy);
68

69 70
BELLESIP_EXPORT belle_sip_uri_t *belle_sip_client_transaction_get_route(belle_sip_client_transaction_t *t);

jehan's avatar
jehan committed
71 72
/**
 * Creates an a sip refresher for transaction like REGISTER/SUBSCRIBE or INVITE which could be refreshed.
jehan's avatar
jehan committed
73
 * Transaction must in be in stated BELLE_SIP_TRANSACTION_COMPLETED. Refresher is created and started. A ref is taken on object transaction
jehan's avatar
jehan committed
74
 * */
75
BELLESIP_EXPORT belle_sip_refresher_t* belle_sip_client_transaction_create_refresher(belle_sip_client_transaction_t *t);
76
/**
jehan's avatar
jehan committed
77 78 79
 * Create an authenticated request based on an existing terminated transaction.
 * <br>This function, update cseq, put route set and try to fill authorization headers. Initial request is not cloned.
 * @param transaction . must be in state completed
80
 * @param auth_infos  if auth infos cannot be added for an authenticate header,
81
 * @param realm optional - If an outbound proxy realm is used, digestion authentication can be optimized.
82
 * a newly allocated belle_sip_auth_info_t object is added to this list. These object contains useful information like realm and username. May be NULL
83
 * */
84
BELLESIP_EXPORT belle_sip_request_t* belle_sip_client_transaction_create_authenticated_request(belle_sip_client_transaction_t *t,belle_sip_list_t** auth_infos,const char* realm);
85

86 87 88 89 90 91
/**
 * For transactions over unreliable transports, stop retransmissions. This avoids for example to keep sending INVITE retransmissions of a call that has just been terminated, while
 * keeping the transaction alive in order to eventually let a response being handled, so that the transaction can be cancelled properly.
**/
BELLESIP_EXPORT void belle_sip_client_transaction_stop_retransmissions(belle_sip_client_transaction_t *t);

92 93 94 95 96
#define BELLE_SIP_TRANSACTION(t) BELLE_SIP_CAST(t,belle_sip_transaction_t)
#define BELLE_SIP_SERVER_TRANSACTION(t) BELLE_SIP_CAST(t,belle_sip_server_transaction_t)
#define BELLE_SIP_CLIENT_TRANSACTION(t) BELLE_SIP_CAST(t,belle_sip_client_transaction_t)


97 98
BELLE_SIP_END_DECLS

99 100
#endif