dialog.h 5.53 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 23 24 25 26 27 28 29 30 31 32 33
    (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_dialog_h
#define belle_sip_dialog_h

enum belle_sip_dialog_state{
	BELLE_SIP_DIALOG_NULL,
	BELLE_SIP_DIALOG_EARLY,
	BELLE_SIP_DIALOG_CONFIRMED,
	BELLE_SIP_DIALOG_TERMINATED
};

typedef enum belle_sip_dialog_state belle_sip_dialog_state_t;

BELLE_SIP_BEGIN_DECLS

34
BELLESIP_EXPORT const char* belle_sip_dialog_state_to_string(const belle_sip_dialog_state_t state);
jehan's avatar
jehan committed
35

36
BELLESIP_EXPORT belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *dialog, unsigned int cseq);
37

38 39 40 41

/**
 * Create a request part of this dialog.
**/
42
BELLESIP_EXPORT belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *dialog, const char *method);
jehan's avatar
jehan committed
43
/**
44
 * Create a request within a dialog keeping non system header from an initial request. This function is very useful to resend request after expiration or chalenge.
jehan's avatar
jehan committed
45 46 47 48
 * @param obj dialog associated to the request
 * @param initial_req, all headers + body are re-used from this request except: Via,From, To, Allows, CSeq, Call-ID, Max-Forwards
 *
 */
Sylvain Berfini's avatar
Sylvain Berfini committed
49
BELLESIP_EXPORT belle_sip_request_t * belle_sip_dialog_create_request_from(belle_sip_dialog_t *obj, const belle_sip_request_t *initial_req);
50

51 52 53 54
/**
 * Create a new request part of this dialog. If dialog is busy (pending transaction), the request can be created anyway and will be sent by the transaction
 * when the dialog becomes available.
**/
55 56
BELLESIP_EXPORT belle_sip_request_t * belle_sip_dialog_create_queued_request(belle_sip_dialog_t *obj, const char *method);

57 58 59 60 61 62 63 64
/**
 * Create a new request part of this dialog keeping non system header from an initial request. If dialog is busy (pending transaction), the request can be created anyway and will be sent by the transaction
 * when the dialog becomes available.
 * @param obj dialog associated to the request
 * @param initial_req, all headers + body are re-used from this request except: Via,From, To, Allows, CSeq, Call-ID, Max-Forwards
**/
BELLESIP_EXPORT belle_sip_request_t *belle_sip_dialog_create_queued_request_from(belle_sip_dialog_t *obj, const belle_sip_request_t *initial_req);

65
BELLESIP_EXPORT void belle_sip_dialog_delete(belle_sip_dialog_t *dialog);
66

Sylvain Berfini's avatar
Sylvain Berfini committed
67
BELLESIP_EXPORT void *belle_sip_dialog_get_application_data(const belle_sip_dialog_t *dialog);
68

Sylvain Berfini's avatar
Sylvain Berfini committed
69
BELLESIP_EXPORT void belle_sip_dialog_set_application_data(belle_sip_dialog_t *dialog, void *data);
70

Sylvain Berfini's avatar
Sylvain Berfini committed
71
BELLESIP_EXPORT const belle_sip_header_call_id_t *belle_sip_dialog_get_call_id(const belle_sip_dialog_t *dialog);
72

Sylvain Berfini's avatar
Sylvain Berfini committed
73
BELLESIP_EXPORT const belle_sip_header_address_t *belle_sip_dialog_get_local_party(const belle_sip_dialog_t *dialog);
74

Sylvain Berfini's avatar
Sylvain Berfini committed
75
BELLESIP_EXPORT const belle_sip_header_address_t *belle_sip_dialog_get_remote_party(const belle_sip_dialog_t *dialog);
76
/**
jehan's avatar
jehan committed
77
 * get the value of the last cseq used to issue a request
78 79
 * @return local cseq
 **/
Sylvain Berfini's avatar
Sylvain Berfini committed
80
BELLESIP_EXPORT unsigned int belle_sip_dialog_get_local_seq_number(const belle_sip_dialog_t *dialog);
81

Simon Morlat's avatar
Simon Morlat committed
82
unsigned int belle_sip_dialog_get_remote_seq_number(const belle_sip_dialog_t *dialog);
83

Sylvain Berfini's avatar
Sylvain Berfini committed
84
BELLESIP_EXPORT const char *belle_sip_dialog_get_local_tag(const belle_sip_dialog_t *dialog);
Simon Morlat's avatar
Simon Morlat committed
85

Sylvain Berfini's avatar
Sylvain Berfini committed
86
BELLESIP_EXPORT const char *belle_sip_dialog_get_remote_tag(const belle_sip_dialog_t *dialog);
87

88
BELLESIP_EXPORT const belle_sip_header_address_t *belle_sip_dialog_get_remote_target(belle_sip_dialog_t *dialog);
89

90
BELLESIP_EXPORT const belle_sip_list_t* belle_sip_dialog_get_route_set(belle_sip_dialog_t *dialog);
91

92
BELLESIP_EXPORT belle_sip_dialog_state_t belle_sip_dialog_get_state(const belle_sip_dialog_t *dialog);
93
/**
94
 * return the dialog state before last transition. Can be useful to detect early avorted dialogs
jehan's avatar
jehan committed
95 96
 * @param dialog
 * @returns state
97
 **/
Sylvain Berfini's avatar
Sylvain Berfini committed
98
BELLESIP_EXPORT belle_sip_dialog_state_t belle_sip_dialog_get_previous_state(const belle_sip_dialog_t *dialog);
jehan's avatar
jehan committed
99

Simon Morlat's avatar
Simon Morlat committed
100

Sylvain Berfini's avatar
Sylvain Berfini committed
101
BELLESIP_EXPORT int belle_sip_dialog_is_server(const belle_sip_dialog_t *dialog);
102

103
BELLESIP_EXPORT int belle_sip_dialog_is_secure(const belle_sip_dialog_t *dialog);
104

105
BELLESIP_EXPORT void belle_sip_dialog_send_ack(belle_sip_dialog_t *dialog, belle_sip_request_t *request);
106

107
BELLESIP_EXPORT void belle_sip_dialog_terminate_on_bye(belle_sip_dialog_t *dialog, int val);
108
/**
109 110 111 112 113
 * Give access to the last transaction processed by a dialog. Can be useful to get reason code for dialog terminated before reaching established state
 * @param dialog
 * @return last transaction
 */
BELLESIP_EXPORT belle_sip_transaction_t* belle_sip_dialog_get_last_transaction(const belle_sip_dialog_t *dialog);
114

115
BELLESIP_EXPORT int belle_sip_dialog_request_pending(const belle_sip_dialog_t *dialog);
116

117 118 119 120
/*for debugging purpose only, allow to disable checking for pending transaction*/
BELLESIP_EXPORT int belle_sip_dialog_pending_trans_checking_enabled( const belle_sip_dialog_t *dialog) ;
BELLESIP_EXPORT int belle_sip_dialog_enable_pending_trans_checking(belle_sip_dialog_t *dialog, int value) ;

Simon Morlat's avatar
Simon Morlat committed
121 122
BELLESIP_EXPORT int belle_sip_dialog_expired(const belle_sip_dialog_t *dialog);

123 124 125 126
BELLE_SIP_END_DECLS

#endif