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 | |
29 | G_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 | |
36 | typedef 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 | */ |
56 | struct _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 | |
100 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
101 | gboolean (*get_binding_data) (GDtlsConnection *conn, |
102 | GTlsChannelBindingType type, |
103 | GByteArray *data, |
104 | GError **error); |
105 | G_GNUC_END_IGNORE_DEPRECATIONS |
106 | }; |
107 | |
108 | GLIB_AVAILABLE_IN_2_48 |
109 | GType g_dtls_connection_get_type (void) G_GNUC_CONST; |
110 | |
111 | GLIB_AVAILABLE_IN_2_48 |
112 | void g_dtls_connection_set_database (GDtlsConnection *conn, |
113 | GTlsDatabase *database); |
114 | GLIB_AVAILABLE_IN_2_48 |
115 | GTlsDatabase *g_dtls_connection_get_database (GDtlsConnection *conn); |
116 | |
117 | GLIB_AVAILABLE_IN_2_48 |
118 | void g_dtls_connection_set_certificate (GDtlsConnection *conn, |
119 | GTlsCertificate *certificate); |
120 | GLIB_AVAILABLE_IN_2_48 |
121 | GTlsCertificate *g_dtls_connection_get_certificate (GDtlsConnection *conn); |
122 | |
123 | GLIB_AVAILABLE_IN_2_48 |
124 | void g_dtls_connection_set_interaction (GDtlsConnection *conn, |
125 | GTlsInteraction *interaction); |
126 | GLIB_AVAILABLE_IN_2_48 |
127 | GTlsInteraction *g_dtls_connection_get_interaction (GDtlsConnection *conn); |
128 | |
129 | GLIB_AVAILABLE_IN_2_48 |
130 | GTlsCertificate *g_dtls_connection_get_peer_certificate (GDtlsConnection *conn); |
131 | GLIB_AVAILABLE_IN_2_48 |
132 | GTlsCertificateFlags g_dtls_connection_get_peer_certificate_errors (GDtlsConnection *conn); |
133 | |
134 | GLIB_AVAILABLE_IN_2_48 |
135 | void g_dtls_connection_set_require_close_notify (GDtlsConnection *conn, |
136 | gboolean require_close_notify); |
137 | GLIB_AVAILABLE_IN_2_48 |
138 | gboolean g_dtls_connection_get_require_close_notify (GDtlsConnection *conn); |
139 | |
140 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
141 | GLIB_DEPRECATED_IN_2_60 |
142 | void g_dtls_connection_set_rehandshake_mode (GDtlsConnection *conn, |
143 | GTlsRehandshakeMode mode); |
144 | GLIB_DEPRECATED_IN_2_60 |
145 | GTlsRehandshakeMode g_dtls_connection_get_rehandshake_mode (GDtlsConnection *conn); |
146 | G_GNUC_END_IGNORE_DEPRECATIONS |
147 | |
148 | GLIB_AVAILABLE_IN_2_48 |
149 | gboolean g_dtls_connection_handshake (GDtlsConnection *conn, |
150 | GCancellable *cancellable, |
151 | GError **error); |
152 | |
153 | GLIB_AVAILABLE_IN_2_48 |
154 | void g_dtls_connection_handshake_async (GDtlsConnection *conn, |
155 | int io_priority, |
156 | GCancellable *cancellable, |
157 | GAsyncReadyCallback callback, |
158 | gpointer user_data); |
159 | GLIB_AVAILABLE_IN_2_48 |
160 | gboolean g_dtls_connection_handshake_finish (GDtlsConnection *conn, |
161 | GAsyncResult *result, |
162 | GError **error); |
163 | |
164 | GLIB_AVAILABLE_IN_2_48 |
165 | gboolean g_dtls_connection_shutdown (GDtlsConnection *conn, |
166 | gboolean shutdown_read, |
167 | gboolean shutdown_write, |
168 | GCancellable *cancellable, |
169 | GError **error); |
170 | |
171 | GLIB_AVAILABLE_IN_2_48 |
172 | void 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); |
179 | GLIB_AVAILABLE_IN_2_48 |
180 | gboolean g_dtls_connection_shutdown_finish (GDtlsConnection *conn, |
181 | GAsyncResult *result, |
182 | GError **error); |
183 | |
184 | GLIB_AVAILABLE_IN_2_48 |
185 | gboolean g_dtls_connection_close (GDtlsConnection *conn, |
186 | GCancellable *cancellable, |
187 | GError **error); |
188 | |
189 | GLIB_AVAILABLE_IN_2_48 |
190 | void g_dtls_connection_close_async (GDtlsConnection *conn, |
191 | int io_priority, |
192 | GCancellable *cancellable, |
193 | GAsyncReadyCallback callback, |
194 | gpointer user_data); |
195 | GLIB_AVAILABLE_IN_2_48 |
196 | gboolean g_dtls_connection_close_finish (GDtlsConnection *conn, |
197 | GAsyncResult *result, |
198 | GError **error); |
199 | |
200 | /*< protected >*/ |
201 | GLIB_AVAILABLE_IN_2_48 |
202 | gboolean g_dtls_connection_emit_accept_certificate (GDtlsConnection *conn, |
203 | GTlsCertificate *peer_cert, |
204 | GTlsCertificateFlags errors); |
205 | GLIB_AVAILABLE_IN_2_60 |
206 | void g_dtls_connection_set_advertised_protocols (GDtlsConnection *conn, |
207 | const gchar * const *protocols); |
208 | |
209 | GLIB_AVAILABLE_IN_2_60 |
210 | const gchar * g_dtls_connection_get_negotiated_protocol (GDtlsConnection *conn); |
211 | |
212 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
213 | GLIB_AVAILABLE_IN_2_66 |
214 | gboolean g_dtls_connection_get_channel_binding_data (GDtlsConnection *conn, |
215 | GTlsChannelBindingType type, |
216 | GByteArray *data, |
217 | GError **error); |
218 | G_GNUC_END_IGNORE_DEPRECATIONS |
219 | |
220 | GLIB_AVAILABLE_IN_2_70 |
221 | GTlsProtocolVersion g_dtls_connection_get_protocol_version (GDtlsConnection *conn); |
222 | |
223 | GLIB_AVAILABLE_IN_2_70 |
224 | gchar * g_dtls_connection_get_ciphersuite_name (GDtlsConnection *conn); |
225 | |
226 | G_END_DECLS |
227 | |
228 | #endif /* __G_DTLS_CONNECTION_H__ */ |
229 | |