gdtlsconnection.h 12 KB

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