1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright © 2010 Red Hat, Inc.
4 * Copyright © 2015 Collabora, Ltd.
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.
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.
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/>.
20 #ifndef __G_DTLS_CONNECTION_H__
21 #define __G_DTLS_CONNECTION_H__
23 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
27 #include <gio/gdatagrambased.h>
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))
36 typedef struct _GDtlsConnectionInterface GDtlsConnectionInterface;
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
49 * @get_negotiated_protocol: Retrieve ALPN-negotiated protocol
51 * Virtual method table for a #GDtlsConnection implementation.
55 struct _GDtlsConnectionInterface
57 GTypeInterface g_iface;
60 gboolean (*accept_certificate) (GDtlsConnection *connection,
61 GTlsCertificate *peer_cert,
62 GTlsCertificateFlags errors);
65 gboolean (*handshake) (GDtlsConnection *conn,
66 GCancellable *cancellable,
69 void (*handshake_async) (GDtlsConnection *conn,
71 GCancellable *cancellable,
72 GAsyncReadyCallback callback,
74 gboolean (*handshake_finish) (GDtlsConnection *conn,
78 gboolean (*shutdown) (GDtlsConnection *conn,
79 gboolean shutdown_read,
80 gboolean shutdown_write,
81 GCancellable *cancellable,
84 void (*shutdown_async) (GDtlsConnection *conn,
85 gboolean shutdown_read,
86 gboolean shutdown_write,
88 GCancellable *cancellable,
89 GAsyncReadyCallback callback,
91 gboolean (*shutdown_finish) (GDtlsConnection *conn,
95 void (*set_advertised_protocols) (GDtlsConnection *conn,
96 const gchar * const *protocols);
97 const gchar *(*get_negotiated_protocol) (GDtlsConnection *conn);
99 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
100 gboolean (*get_binding_data) (GDtlsConnection *conn,
101 GTlsChannelBindingType type,
104 G_GNUC_END_IGNORE_DEPRECATIONS
107 GLIB_AVAILABLE_IN_2_48
108 GType g_dtls_connection_get_type (void) G_GNUC_CONST;
110 GLIB_AVAILABLE_IN_2_48
111 void g_dtls_connection_set_database (GDtlsConnection *conn,
112 GTlsDatabase *database);
113 GLIB_AVAILABLE_IN_2_48
114 GTlsDatabase *g_dtls_connection_get_database (GDtlsConnection *conn);
116 GLIB_AVAILABLE_IN_2_48
117 void g_dtls_connection_set_certificate (GDtlsConnection *conn,
118 GTlsCertificate *certificate);
119 GLIB_AVAILABLE_IN_2_48
120 GTlsCertificate *g_dtls_connection_get_certificate (GDtlsConnection *conn);
122 GLIB_AVAILABLE_IN_2_48
123 void g_dtls_connection_set_interaction (GDtlsConnection *conn,
124 GTlsInteraction *interaction);
125 GLIB_AVAILABLE_IN_2_48
126 GTlsInteraction *g_dtls_connection_get_interaction (GDtlsConnection *conn);
128 GLIB_AVAILABLE_IN_2_48
129 GTlsCertificate *g_dtls_connection_get_peer_certificate (GDtlsConnection *conn);
130 GLIB_AVAILABLE_IN_2_48
131 GTlsCertificateFlags g_dtls_connection_get_peer_certificate_errors (GDtlsConnection *conn);
133 GLIB_AVAILABLE_IN_2_48
134 void g_dtls_connection_set_require_close_notify (GDtlsConnection *conn,
135 gboolean require_close_notify);
136 GLIB_AVAILABLE_IN_2_48
137 gboolean g_dtls_connection_get_require_close_notify (GDtlsConnection *conn);
139 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
140 GLIB_DEPRECATED_IN_2_60
141 void g_dtls_connection_set_rehandshake_mode (GDtlsConnection *conn,
142 GTlsRehandshakeMode mode);
143 GLIB_DEPRECATED_IN_2_60
144 GTlsRehandshakeMode g_dtls_connection_get_rehandshake_mode (GDtlsConnection *conn);
145 G_GNUC_END_IGNORE_DEPRECATIONS
147 GLIB_AVAILABLE_IN_2_48
148 gboolean g_dtls_connection_handshake (GDtlsConnection *conn,
149 GCancellable *cancellable,
152 GLIB_AVAILABLE_IN_2_48
153 void g_dtls_connection_handshake_async (GDtlsConnection *conn,
155 GCancellable *cancellable,
156 GAsyncReadyCallback callback,
158 GLIB_AVAILABLE_IN_2_48
159 gboolean g_dtls_connection_handshake_finish (GDtlsConnection *conn,
160 GAsyncResult *result,
163 GLIB_AVAILABLE_IN_2_48
164 gboolean g_dtls_connection_shutdown (GDtlsConnection *conn,
165 gboolean shutdown_read,
166 gboolean shutdown_write,
167 GCancellable *cancellable,
170 GLIB_AVAILABLE_IN_2_48
171 void g_dtls_connection_shutdown_async (GDtlsConnection *conn,
172 gboolean shutdown_read,
173 gboolean shutdown_write,
175 GCancellable *cancellable,
176 GAsyncReadyCallback callback,
178 GLIB_AVAILABLE_IN_2_48
179 gboolean g_dtls_connection_shutdown_finish (GDtlsConnection *conn,
180 GAsyncResult *result,
183 GLIB_AVAILABLE_IN_2_48
184 gboolean g_dtls_connection_close (GDtlsConnection *conn,
185 GCancellable *cancellable,
188 GLIB_AVAILABLE_IN_2_48
189 void g_dtls_connection_close_async (GDtlsConnection *conn,
191 GCancellable *cancellable,
192 GAsyncReadyCallback callback,
194 GLIB_AVAILABLE_IN_2_48
195 gboolean g_dtls_connection_close_finish (GDtlsConnection *conn,
196 GAsyncResult *result,
200 GLIB_AVAILABLE_IN_2_48
201 gboolean g_dtls_connection_emit_accept_certificate (GDtlsConnection *conn,
202 GTlsCertificate *peer_cert,
203 GTlsCertificateFlags errors);
204 GLIB_AVAILABLE_IN_2_60
205 void g_dtls_connection_set_advertised_protocols (GDtlsConnection *conn,
206 const gchar * const *protocols);
208 GLIB_AVAILABLE_IN_2_60
209 const gchar * g_dtls_connection_get_negotiated_protocol (GDtlsConnection *conn);
211 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
212 GLIB_AVAILABLE_IN_2_66
213 gboolean g_dtls_connection_get_channel_binding_data (GDtlsConnection *conn,
214 GTlsChannelBindingType type,
217 G_GNUC_END_IGNORE_DEPRECATIONS
221 #endif /* __G_DTLS_CONNECTION_H__ */