1 /*
2  * Copyright (C) 2011-2012 Free Software Foundation, Inc.
3  *
4  * Author: Nikos Mavrogiannopoulos
5  *
6  * This file is part of GnuTLS.
7  *
8  * The GnuTLS is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <https://www.gnu.org/licenses/>
20  *
21  */
22 
23 /* This file contains the types and prototypes for the X.509
24  * certificate and CRL handling functions.
25  */
26 
27 #ifndef GNUTLS_DTLS_H
28 #define GNUTLS_DTLS_H
29 
30 #include <gnutls/gnutls.h>
31 
32 /* *INDENT-OFF* */
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 /* *INDENT-ON* */
37 
38 #define GNUTLS_COOKIE_KEY_SIZE 16
39 
40 void gnutls_dtls_set_timeouts(gnutls_session_t session,
41 			      unsigned int retrans_timeout,
42 			      unsigned int total_timeout);
43 
44 unsigned int gnutls_dtls_get_mtu(gnutls_session_t session);
45 unsigned int gnutls_dtls_get_data_mtu(gnutls_session_t session);
46 
47 void gnutls_dtls_set_mtu(gnutls_session_t session, unsigned int mtu);
48 int gnutls_dtls_set_data_mtu(gnutls_session_t session, unsigned int mtu);
49 
50 unsigned int gnutls_dtls_get_timeout(gnutls_session_t session);
51 
52 /**
53  * gnutls_dtls_prestate_st:
54  * @record_seq: record sequence number
55  * @hsk_read_seq: handshake read sequence number
56  * @hsk_write_seq: handshake write sequence number
57  *
58  * DTLS cookie prestate struct.  This is usually never modified by
59  * the application, it is used to carry the cookie data between
60  * gnutls_dtls_cookie_send(), gnutls_dtls_cookie_verify() and
61  * gnutls_dtls_prestate_set().
62  */
63 typedef struct {
64 	unsigned int record_seq;
65 	unsigned int hsk_read_seq;
66 	unsigned int hsk_write_seq;
67 } gnutls_dtls_prestate_st;
68 
69 int gnutls_dtls_cookie_send(gnutls_datum_t * key,
70 			    void *client_data,
71 			    size_t client_data_size,
72 			    gnutls_dtls_prestate_st * prestate,
73 			    gnutls_transport_ptr_t ptr,
74 			    gnutls_push_func push_func);
75 
76 int gnutls_dtls_cookie_verify(gnutls_datum_t * key,
77 			      void *client_data,
78 			      size_t client_data_size, void *_msg,
79 			      size_t msg_size,
80 			      gnutls_dtls_prestate_st * prestate);
81 
82 void gnutls_dtls_prestate_set(gnutls_session_t session,
83 			      gnutls_dtls_prestate_st * prestate);
84 
85 unsigned int gnutls_record_get_discarded(gnutls_session_t session);
86 
87 /* *INDENT-OFF* */
88 #ifdef __cplusplus
89 }
90 #endif
91 /* *INDENT-ON* */
92 #endif				/* GNUTLS_DTLS_H */
93