1 /*
2 	belle-sip - SIP (RFC3261) library.
3     Copyright (C) 2010  Belledonne Communications SARL
4 
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.
9 
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.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 #ifndef belle_sip_dialog_h
21 #define belle_sip_dialog_h
22 
23 enum belle_sip_dialog_state{
24 	BELLE_SIP_DIALOG_NULL,
25 	BELLE_SIP_DIALOG_EARLY,
26 	BELLE_SIP_DIALOG_CONFIRMED,
27 	BELLE_SIP_DIALOG_TERMINATED
28 };
29 
30 typedef enum belle_sip_dialog_state belle_sip_dialog_state_t;
31 
32 BELLE_SIP_BEGIN_DECLS
33 
34 BELLESIP_EXPORT const char* belle_sip_dialog_state_to_string(const belle_sip_dialog_state_t state);
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  * Create a request part of this dialog.
41 **/
42 BELLESIP_EXPORT belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *dialog, const char *method);
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.
45  * @param obj dialog associated to the request
46  * @param initial_req, all headers + body are re-used from this request except: Via,From, To, Allows, CSeq, Call-ID, Max-Forwards
47  *
48  */
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  * 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
53  * when the dialog becomes available.
54 **/
55 BELLESIP_EXPORT belle_sip_request_t * belle_sip_dialog_create_queued_request(belle_sip_dialog_t *obj, const char *method);
56 
57 /**
58  * 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
59  * when the dialog becomes available.
60  * @param obj dialog associated to the request
61  * @param initial_req, all headers + body are re-used from this request except: Via,From, To, Allows, CSeq, Call-ID, Max-Forwards
62 **/
63 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);
64 
65 BELLESIP_EXPORT void belle_sip_dialog_delete(belle_sip_dialog_t *dialog);
66 
67 BELLESIP_EXPORT void *belle_sip_dialog_get_application_data(const belle_sip_dialog_t *dialog);
68 
69 BELLESIP_EXPORT void belle_sip_dialog_set_application_data(belle_sip_dialog_t *dialog, void *data);
70 
71 BELLESIP_EXPORT const belle_sip_header_call_id_t *belle_sip_dialog_get_call_id(const belle_sip_dialog_t *dialog);
72 
73 BELLESIP_EXPORT const belle_sip_header_address_t *belle_sip_dialog_get_local_party(const belle_sip_dialog_t *dialog);
74 
75 BELLESIP_EXPORT const belle_sip_header_address_t *belle_sip_dialog_get_remote_party(const belle_sip_dialog_t *dialog);
76 /**
77  * get the value of the last cseq used to issue a request
78  * @return local cseq
79  **/
80 BELLESIP_EXPORT unsigned int belle_sip_dialog_get_local_seq_number(const belle_sip_dialog_t *dialog);
81 
82 unsigned int belle_sip_dialog_get_remote_seq_number(const belle_sip_dialog_t *dialog);
83 
84 BELLESIP_EXPORT const char *belle_sip_dialog_get_local_tag(const belle_sip_dialog_t *dialog);
85 
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
95  * @param dialog
96  * @returns state
97  **/
98 BELLESIP_EXPORT belle_sip_dialog_state_t belle_sip_dialog_get_previous_state(const belle_sip_dialog_t *dialog);
99 
100 
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  * Give access to the last transaction processed by a dialog. Can be useful to get reason code for dialog terminated before reaching established state
110  * @param dialog
111  * @return last transaction
112  */
113 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 /*for debugging purpose only, allow to disable checking for pending transaction*/
118 BELLESIP_EXPORT int belle_sip_dialog_pending_trans_checking_enabled( const belle_sip_dialog_t *dialog) ;
119 BELLESIP_EXPORT int belle_sip_dialog_enable_pending_trans_checking(belle_sip_dialog_t *dialog, int value) ;
120 
121 BELLESIP_EXPORT int belle_sip_dialog_expired(const belle_sip_dialog_t *dialog);
122 
123 BELLE_SIP_END_DECLS
124 
125 #endif
126 
127