chenqiyang
2021-08-20 7b95fb4d4549d3452ee17165236186afc1f2b393
1
2
3
4
5
6
7
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
 * Copyright (c) 2010-2019 Belledonne Communications SARL.
 *
 * This file is part of Liblinphone.
 *
 * 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
 * the Free Software Foundation, either version 3 of the License, or
 * (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 LINPHONE_NAT_POLICY_H_
#define LINPHONE_NAT_POLICY_H_
 
 
#include "linphone/types.h"
 
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
/**
 * @addtogroup network_parameters
 * @{
 */
 
/**
 * Acquire a reference to the #LinphoneNatPolicy object.
 * @param[in] policy #LinphoneNatPolicy object.
 * @return The same #LinphoneNatPolicy object.
**/
LINPHONE_PUBLIC LinphoneNatPolicy * linphone_nat_policy_ref(LinphoneNatPolicy *policy);
 
/**
 * Release reference to the #LinphoneNatPolicy object.
 * @param[in] policy #LinphoneNatPolicy object.
**/
LINPHONE_PUBLIC void linphone_nat_policy_unref(LinphoneNatPolicy *policy);
 
/**
 * Retrieve the user pointer associated with the #LinphoneNatPolicy object.
 * @param[in] policy #LinphoneNatPolicy object.
 * @return The user pointer associated with the #LinphoneNatPolicy object.
**/
LINPHONE_PUBLIC void *linphone_nat_policy_get_user_data(const LinphoneNatPolicy *policy);
 
/**
 * Assign a user pointer to the #LinphoneNatPolicy object.
 * @param[in] policy #LinphoneNatPolicy object.
 * @param[in] ud The user pointer to associate with the #LinphoneNatPolicy object.
**/
LINPHONE_PUBLIC void linphone_nat_policy_set_user_data(LinphoneNatPolicy *policy, void *ud);
 
/**
 * Clear a NAT policy (deactivate all protocols and unset the STUN server).
 * @param[in] policy #LinphoneNatPolicy object.
 */
LINPHONE_PUBLIC void linphone_nat_policy_clear(LinphoneNatPolicy *policy);
 
/**
 * Tell whether STUN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether STUN is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_stun_enabled(const LinphoneNatPolicy *policy);
 
/**
 * Enable STUN.
 * If TURN is also enabled, TURN will be used instead of STUN.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable STUN.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_stun(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Tell whether TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether TURN is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_turn_enabled(const LinphoneNatPolicy *policy);
 
/**
 * Enable TURN.
 * If STUN is also enabled, it is ignored and TURN is used.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable TURN.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_turn(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Tell whether ICE is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether ICE is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_ice_enabled(const LinphoneNatPolicy *policy);
 
/**
 * Enable ICE.
 * ICE can be enabled without STUN/TURN, in which case only the local candidates will be used.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable ICE.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_ice(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Tell whether uPnP is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether uPnP is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_upnp_enabled(const LinphoneNatPolicy *policy);
 
/**
 * Enable uPnP.
 * This has the effect to disable every other policies (ICE, STUN and TURN).
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable uPnP.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_upnp(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Get the STUN/TURN server to use with this NAT policy.
 * Used when STUN or TURN are enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return The STUN server used by this NAT policy.
 */
LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server(const LinphoneNatPolicy *policy);
 
/**
 * Set the STUN/TURN server to use with this NAT policy.
 * Used when STUN or TURN are enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] stun_server The STUN server to use with this NAT policy.
 */
LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *stun_server);
 
/**
 * Get the username used to authenticate with the STUN/TURN server.
 * The authentication will search for a #LinphoneAuthInfo with this username.
 * If it is not set the username of the currently used #LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
 * @param[in] policy #LinphoneNatPolicy object
 * @return The username used to authenticate with the STUN/TURN server.
 */
LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy *policy);
 
/**
 * Set the username used to authenticate with the STUN/TURN server.
 * The authentication will search for a #LinphoneAuthInfo with this username.
 * If it is not set the username of the currently used #LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] username The username used to authenticate with the STUN/TURN server.
 */
LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, const char *username);
 
/**
 * Start a STUN server DNS resolution.
 * @param[in] policy #LinphoneNatPolicy object
 */
LINPHONE_PUBLIC void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy);
 
/**
 * Get the addrinfo representation of the STUN server address.
 * WARNING: This function may block for up to 1 second.
 * @param[in] policy #LinphoneNatPolicy object
 * @return addrinfo representation of the STUN server address.
 * @donotwrap
 */
LINPHONE_PUBLIC const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNatPolicy *policy);
 
/**
 * Enable UDP TURN transport.
 * Used when TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable UDP TURN transport.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_udp_turn_transport(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Tells whether UDP TURN transport is enabled.
 * Used when TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether UDP TURN transport is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_udp_turn_transport_enabled(LinphoneNatPolicy *policy);
 
/**
 * Enable TCP TURN transport.
 * Used when TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable TCP TURN transport.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_tcp_turn_transport(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Tells whether TCP TURN transport is enabled.
 * Used when TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether TCP TURN transport is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_tcp_turn_transport_enabled(LinphoneNatPolicy *policy);
 
/**
 * Enable TLS TURN transport.
 * Used when TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @param[in] enable Boolean value telling whether to enable TLS TURN transport.
 */
LINPHONE_PUBLIC void linphone_nat_policy_enable_tls_turn_transport(LinphoneNatPolicy *policy, bool_t enable);
 
/**
 * Tells whether TLS TURN transport is enabled.
 * Used when TURN is enabled.
 * @param[in] policy #LinphoneNatPolicy object
 * @return Boolean value telling whether TLS TURN transport is enabled.
 */
LINPHONE_PUBLIC bool_t linphone_nat_policy_tls_turn_transport_enabled(LinphoneNatPolicy *policy);
 
/**
 * Returns the #LinphoneCore object managing this nat policy, if any.
 * @param[in] fr #LinphoneNatPolicy object
 */
LINPHONE_PUBLIC LinphoneCore *linphone_nat_policy_get_core(const LinphoneNatPolicy *policy);
 
/**
 * @}
 */
 
 
#ifdef __cplusplus
}
#endif
 
#endif /* LINPHONE_NAT_POLICY_H_ */