diff options
Diffstat (limited to 'src/daemon/https/tls/ext_server_name.c')
-rw-r--r-- | src/daemon/https/tls/ext_server_name.c | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/src/daemon/https/tls/ext_server_name.c b/src/daemon/https/tls/ext_server_name.c index 1e3cab02..d7f945d6 100644 --- a/src/daemon/https/tls/ext_server_name.c +++ b/src/daemon/https/tls/ext_server_name.c | |||
@@ -209,122 +209,3 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, | |||
209 | return total_size; | 209 | return total_size; |
210 | } | 210 | } |
211 | 211 | ||
212 | /** | ||
213 | * MHD__gnutls_server_name_get - Used to get the server name indicator send by a client | ||
214 | * @session: is a #MHD_gtls_session_t structure. | ||
215 | * @data: will hold the data | ||
216 | * @data_length: will hold the data length. Must hold the maximum size of data. | ||
217 | * @type: will hold the server name indicator type | ||
218 | * @indx: is the index of the server_name | ||
219 | * | ||
220 | * This function will allow you to get the name indication (if any), | ||
221 | * a client has sent. The name indication may be any of the enumeration | ||
222 | * MHD_gnutls_server_name_type_t. | ||
223 | * | ||
224 | * If @type is GNUTLS_NAME_DNS, then this function is to be used by servers | ||
225 | * that support virtual hosting, and the data will be a null terminated UTF-8 string. | ||
226 | * | ||
227 | * If @data has not enough size to hold the server name GNUTLS_E_SHORT_MEMORY_BUFFER | ||
228 | * is returned, and @data_length will hold the required size. | ||
229 | * | ||
230 | * @index is used to retrieve more than one server names (if sent by the client). | ||
231 | * The first server name has an index of 0, the second 1 and so on. If no name with the given | ||
232 | * index exists GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned. | ||
233 | * | ||
234 | **/ | ||
235 | int | ||
236 | MHD__gnutls_server_name_get (MHD_gtls_session_t session, void *data, | ||
237 | size_t * data_length, | ||
238 | unsigned int *type, unsigned int indx) | ||
239 | { | ||
240 | char *_data = data; | ||
241 | #if MHD_DEBUG_TLS | ||
242 | if (session->security_parameters.entity == GNUTLS_CLIENT) | ||
243 | { | ||
244 | MHD_gnutls_assert (); | ||
245 | return GNUTLS_E_INVALID_REQUEST; | ||
246 | } | ||
247 | #endif | ||
248 | if (indx + 1 > session->security_parameters.extensions.server_names_size) | ||
249 | { | ||
250 | return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; | ||
251 | } | ||
252 | |||
253 | *type = session->security_parameters.extensions.server_names[indx].type; | ||
254 | |||
255 | if (*data_length > /* greater since we need one extra byte for the null */ | ||
256 | session->security_parameters.extensions.server_names[indx].name_length) | ||
257 | { | ||
258 | *data_length = | ||
259 | session->security_parameters.extensions. | ||
260 | server_names[indx].name_length; | ||
261 | memcpy (data, | ||
262 | session->security_parameters.extensions.server_names[indx].name, | ||
263 | *data_length); | ||
264 | |||
265 | if (*type == GNUTLS_NAME_DNS) /* null terminate */ | ||
266 | _data[(*data_length)] = 0; | ||
267 | |||
268 | } | ||
269 | else | ||
270 | { | ||
271 | *data_length = | ||
272 | session->security_parameters.extensions. | ||
273 | server_names[indx].name_length; | ||
274 | return GNUTLS_E_SHORT_MEMORY_BUFFER; | ||
275 | } | ||
276 | |||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | /** | ||
281 | * MHD__gnutls_server_name_set - Used to set a name indicator to be sent as an extension | ||
282 | * @session: is a #MHD_gtls_session_t structure. | ||
283 | * @type: specifies the indicator type | ||
284 | * @name: is a string that contains the server name. | ||
285 | * @name_length: holds the length of name | ||
286 | * | ||
287 | * This function is to be used by clients that want to inform | ||
288 | * (via a TLS extension mechanism) the server of the name they | ||
289 | * connected to. This should be used by clients that connect | ||
290 | * to servers that do virtual hosting. | ||
291 | * | ||
292 | * The value of @name depends on the @ind type. In case of GNUTLS_NAME_DNS, | ||
293 | * an ASCII or UTF-8 null terminated string, without the trailing dot, is expected. | ||
294 | * IPv4 or IPv6 addresses are not permitted. | ||
295 | * | ||
296 | **/ | ||
297 | int | ||
298 | MHD__gnutls_server_name_set (MHD_gtls_session_t session, | ||
299 | MHD_gnutls_server_name_type_t type, | ||
300 | const void *name, size_t name_length) | ||
301 | { | ||
302 | int server_names; | ||
303 | |||
304 | if (session->security_parameters.entity == GNUTLS_SERVER) | ||
305 | { | ||
306 | MHD_gnutls_assert (); | ||
307 | return GNUTLS_E_INVALID_REQUEST; | ||
308 | } | ||
309 | |||
310 | if (name_length > MAX_SERVER_NAME_SIZE) | ||
311 | return GNUTLS_E_SHORT_MEMORY_BUFFER; | ||
312 | |||
313 | server_names = | ||
314 | session->security_parameters.extensions.server_names_size + 1; | ||
315 | |||
316 | if (server_names > MAX_SERVER_NAME_EXTENSIONS) | ||
317 | server_names = MAX_SERVER_NAME_EXTENSIONS; | ||
318 | |||
319 | session->security_parameters.extensions.server_names[server_names - | ||
320 | 1].type = type; | ||
321 | memcpy (session->security_parameters. | ||
322 | extensions.server_names[server_names - 1].name, name, name_length); | ||
323 | session->security_parameters.extensions.server_names[server_names - | ||
324 | 1].name_length = | ||
325 | name_length; | ||
326 | |||
327 | session->security_parameters.extensions.server_names_size++; | ||
328 | |||
329 | return 0; | ||
330 | } | ||