1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright © 2010 Red Hat, Inc.
4 * Copyright © 2015 Collabora, Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __G_DTLS_CONNECTION_H__
21#define __G_DTLS_CONNECTION_H__
22
23#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24#error "Only <gio/gio.h> can be included directly."
25#endif
26
27#include <gio/gdatagrambased.h>
28
29G_BEGIN_DECLS
30
31#define G_TYPE_DTLS_CONNECTION (g_dtls_connection_get_type ())
32#define G_DTLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_DTLS_CONNECTION, GDtlsConnection))
33#define G_IS_DTLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_DTLS_CONNECTION))
34#define G_DTLS_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_DTLS_CONNECTION, GDtlsConnectionInterface))
35
36typedef struct _GDtlsConnectionInterface GDtlsConnectionInterface;
37
38/**
39 * GDtlsConnectionInterface:
40 * @g_iface: The parent interface.
41 * @accept_certificate: Check whether to accept a certificate.
42 * @handshake: Perform a handshake operation.
43 * @handshake_async: Start an asynchronous handshake operation.
44 * @handshake_finish: Finish an asynchronous handshake operation.
45 * @shutdown: Shut down one or both directions of the connection.
46 * @shutdown_async: Start an asynchronous shutdown operation.
47 * @shutdown_finish: Finish an asynchronous shutdown operation.
48 * @set_advertised_protocols: Set APLN protocol list (Since: 2.60)
49 * @get_negotiated_protocol: Get ALPN-negotiated protocol (Since: 2.60)
50 * @get_binding_data: Retrieve TLS channel binding data (Since: 2.66)
51 *
52 * Virtual method table for a #GDtlsConnection implementation.
53 *
54 * Since: 2.48
55 */
56struct _GDtlsConnectionInterface
57{
58 GTypeInterface g_iface;
59
60 /* signals */
61 gboolean (*accept_certificate) (GDtlsConnection *connection,
62 GTlsCertificate *peer_cert,
63 GTlsCertificateFlags errors);
64
65 /* methods */
66 gboolean (*handshake) (GDtlsConnection *conn,
67 GCancellable *cancellable,
68 GError **error);
69
70 void (*handshake_async) (GDtlsConnection *conn,
71 int io_priority,
72 GCancellable *cancellable,
73 GAsyncReadyCallback callback,
74 gpointer user_data);
75 gboolean (*handshake_finish) (GDtlsConnection *conn,
76 GAsyncResult *result,
77 GError **error);
78
79 gboolean (*shutdown) (GDtlsConnection *conn,
80 gboolean shutdown_read,
81 gboolean shutdown_write,
82 GCancellable *cancellable,
83 GError **error);
84
85 void (*shutdown_async) (GDtlsConnection *conn,
86 gboolean shutdown_read,
87 gboolean shutdown_write,
88 int io_priority,
89 GCancellable *cancellable,
90 GAsyncReadyCallback callback,
91 gpointer user_data);
92 gboolean (*shutdown_finish) (GDtlsConnection *conn,
93 GAsyncResult *result,
94 GError **error);
95
96 void (*set_advertised_protocols) (GDtlsConnection *conn,
97 const gchar * const *protocols);
98 const gchar *(*get_negotiated_protocol) (GDtlsConnection *conn);
99
100G_GNUC_BEGIN_IGNORE_DEPRECATIONS
101 gboolean (*get_binding_data) (GDtlsConnection *conn,
102 GTlsChannelBindingType type,
103 GByteArray *data,
104 GError **error);
105G_GNUC_END_IGNORE_DEPRECATIONS
106};
107
108GLIB_AVAILABLE_IN_2_48
109GType g_dtls_connection_get_type (void) G_GNUC_CONST;
110
111GLIB_AVAILABLE_IN_2_48
112void g_dtls_connection_set_database (GDtlsConnection *conn,
113 GTlsDatabase *database);
114GLIB_AVAILABLE_IN_2_48
115GTlsDatabase *g_dtls_connection_get_database (GDtlsConnection *conn);
116
117GLIB_AVAILABLE_IN_2_48
118void g_dtls_connection_set_certificate (GDtlsConnection *conn,
119 GTlsCertificate *certificate);
120GLIB_AVAILABLE_IN_2_48
121GTlsCertificate *g_dtls_connection_get_certificate (GDtlsConnection *conn);
122
123GLIB_AVAILABLE_IN_2_48
124void g_dtls_connection_set_interaction (GDtlsConnection *conn,
125 GTlsInteraction *interaction);
126GLIB_AVAILABLE_IN_2_48
127GTlsInteraction *g_dtls_connection_get_interaction (GDtlsConnection *conn);
128
129GLIB_AVAILABLE_IN_2_48
130GTlsCertificate *g_dtls_connection_get_peer_certificate (GDtlsConnection *conn);
131GLIB_AVAILABLE_IN_2_48
132GTlsCertificateFlags g_dtls_connection_get_peer_certificate_errors (GDtlsConnection *conn);
133
134GLIB_AVAILABLE_IN_2_48
135void g_dtls_connection_set_require_close_notify (GDtlsConnection *conn,
136 gboolean require_close_notify);
137GLIB_AVAILABLE_IN_2_48
138gboolean g_dtls_connection_get_require_close_notify (GDtlsConnection *conn);
139
140G_GNUC_BEGIN_IGNORE_DEPRECATIONS
141GLIB_DEPRECATED_IN_2_60
142void g_dtls_connection_set_rehandshake_mode (GDtlsConnection *conn,
143 GTlsRehandshakeMode mode);
144GLIB_DEPRECATED_IN_2_60
145GTlsRehandshakeMode g_dtls_connection_get_rehandshake_mode (GDtlsConnection *conn);
146G_GNUC_END_IGNORE_DEPRECATIONS
147
148GLIB_AVAILABLE_IN_2_48
149gboolean g_dtls_connection_handshake (GDtlsConnection *conn,
150 GCancellable *cancellable,
151 GError **error);
152
153GLIB_AVAILABLE_IN_2_48
154void g_dtls_connection_handshake_async (GDtlsConnection *conn,
155 int io_priority,
156 GCancellable *cancellable,
157 GAsyncReadyCallback callback,
158 gpointer user_data);
159GLIB_AVAILABLE_IN_2_48
160gboolean g_dtls_connection_handshake_finish (GDtlsConnection *conn,
161 GAsyncResult *result,
162 GError **error);
163
164GLIB_AVAILABLE_IN_2_48
165gboolean g_dtls_connection_shutdown (GDtlsConnection *conn,
166 gboolean shutdown_read,
167 gboolean shutdown_write,
168 GCancellable *cancellable,
169 GError **error);
170
171GLIB_AVAILABLE_IN_2_48
172void g_dtls_connection_shutdown_async (GDtlsConnection *conn,
173 gboolean shutdown_read,
174 gboolean shutdown_write,
175 int io_priority,
176 GCancellable *cancellable,
177 GAsyncReadyCallback callback,
178 gpointer user_data);
179GLIB_AVAILABLE_IN_2_48
180gboolean g_dtls_connection_shutdown_finish (GDtlsConnection *conn,
181 GAsyncResult *result,
182 GError **error);
183
184GLIB_AVAILABLE_IN_2_48
185gboolean g_dtls_connection_close (GDtlsConnection *conn,
186 GCancellable *cancellable,
187 GError **error);
188
189GLIB_AVAILABLE_IN_2_48
190void g_dtls_connection_close_async (GDtlsConnection *conn,
191 int io_priority,
192 GCancellable *cancellable,
193 GAsyncReadyCallback callback,
194 gpointer user_data);
195GLIB_AVAILABLE_IN_2_48
196gboolean g_dtls_connection_close_finish (GDtlsConnection *conn,
197 GAsyncResult *result,
198 GError **error);
199
200/*< protected >*/
201GLIB_AVAILABLE_IN_2_48
202gboolean g_dtls_connection_emit_accept_certificate (GDtlsConnection *conn,
203 GTlsCertificate *peer_cert,
204 GTlsCertificateFlags errors);
205GLIB_AVAILABLE_IN_2_60
206void g_dtls_connection_set_advertised_protocols (GDtlsConnection *conn,
207 const gchar * const *protocols);
208
209GLIB_AVAILABLE_IN_2_60
210const gchar * g_dtls_connection_get_negotiated_protocol (GDtlsConnection *conn);
211
212G_GNUC_BEGIN_IGNORE_DEPRECATIONS
213GLIB_AVAILABLE_IN_2_66
214gboolean g_dtls_connection_get_channel_binding_data (GDtlsConnection *conn,
215 GTlsChannelBindingType type,
216 GByteArray *data,
217 GError **error);
218G_GNUC_END_IGNORE_DEPRECATIONS
219
220GLIB_AVAILABLE_IN_2_70
221GTlsProtocolVersion g_dtls_connection_get_protocol_version (GDtlsConnection *conn);
222
223GLIB_AVAILABLE_IN_2_70
224gchar * g_dtls_connection_get_ciphersuite_name (GDtlsConnection *conn);
225
226G_END_DECLS
227
228#endif /* __G_DTLS_CONNECTION_H__ */
229

source code of include/glib-2.0/gio/gdtlsconnection.h