gdtlsconnection.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. #ifndef __G_DTLS_CONNECTION_H__
  20. #define __G_DTLS_CONNECTION_H__
  21. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  22. #error "Only <gio/gio.h> can be included directly."
  23. #endif
  24. #include <gio/gdatagrambased.h>
  25. G_BEGIN_DECLS
  26. #define G_TYPE_DTLS_CONNECTION (g_dtls_connection_get_type ())
  27. #define G_DTLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_DTLS_CONNECTION, GDtlsConnection))
  28. #define G_IS_DTLS_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_DTLS_CONNECTION))
  29. #define G_DTLS_CONNECTION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_DTLS_CONNECTION, GDtlsConnectionInterface))
  30. typedef struct _GDtlsConnectionInterface GDtlsConnectionInterface;
  31. /**
  32. * GDtlsConnectionInterface:
  33. * @g_iface: The parent interface.
  34. * @accept_certificate: Check whether to accept a certificate.
  35. * @handshake: Perform a handshake operation.
  36. * @handshake_async: Start an asynchronous handshake operation.
  37. * @handshake_finish: Finish an asynchronous handshake operation.
  38. * @shutdown: Shut down one or both directions of the connection.
  39. * @shutdown_async: Start an asynchronous shutdown operation.
  40. * @shutdown_finish: Finish an asynchronous shutdown operation.
  41. * @set_advertised_protocols: Set APLN protocol list
  42. * @get_negotiated_protocol: Retrieve ALPN-negotiated protocol
  43. *
  44. * Virtual method table for a #GDtlsConnection implementation.
  45. *
  46. * Since: 2.48
  47. */
  48. struct _GDtlsConnectionInterface
  49. {
  50. GTypeInterface g_iface;
  51. /* signals */
  52. gboolean (*accept_certificate) (GDtlsConnection *connection,
  53. GTlsCertificate *peer_cert,
  54. GTlsCertificateFlags errors);
  55. /* methods */
  56. gboolean (*handshake) (GDtlsConnection *conn,
  57. GCancellable *cancellable,
  58. GError **error);
  59. void (*handshake_async) (GDtlsConnection *conn,
  60. int io_priority,
  61. GCancellable *cancellable,
  62. GAsyncReadyCallback callback,
  63. gpointer user_data);
  64. gboolean (*handshake_finish) (GDtlsConnection *conn,
  65. GAsyncResult *result,
  66. GError **error);
  67. gboolean (*shutdown) (GDtlsConnection *conn,
  68. gboolean shutdown_read,
  69. gboolean shutdown_write,
  70. GCancellable *cancellable,
  71. GError **error);
  72. void (*shutdown_async) (GDtlsConnection *conn,
  73. gboolean shutdown_read,
  74. gboolean shutdown_write,
  75. int io_priority,
  76. GCancellable *cancellable,
  77. GAsyncReadyCallback callback,
  78. gpointer user_data);
  79. gboolean (*shutdown_finish) (GDtlsConnection *conn,
  80. GAsyncResult *result,
  81. GError **error);
  82. void (*set_advertised_protocols) (GDtlsConnection *conn,
  83. const gchar * const *protocols);
  84. const gchar *(*get_negotiated_protocol) (GDtlsConnection *conn);
  85. };
  86. GLIB_AVAILABLE_IN_2_48
  87. GType g_dtls_connection_get_type (void) G_GNUC_CONST;
  88. GLIB_AVAILABLE_IN_2_48
  89. void g_dtls_connection_set_database (GDtlsConnection *conn,
  90. GTlsDatabase *database);
  91. GLIB_AVAILABLE_IN_2_48
  92. GTlsDatabase *g_dtls_connection_get_database (GDtlsConnection *conn);
  93. GLIB_AVAILABLE_IN_2_48
  94. void g_dtls_connection_set_certificate (GDtlsConnection *conn,
  95. GTlsCertificate *certificate);
  96. GLIB_AVAILABLE_IN_2_48
  97. GTlsCertificate *g_dtls_connection_get_certificate (GDtlsConnection *conn);
  98. GLIB_AVAILABLE_IN_2_48
  99. void g_dtls_connection_set_interaction (GDtlsConnection *conn,
  100. GTlsInteraction *interaction);
  101. GLIB_AVAILABLE_IN_2_48
  102. GTlsInteraction *g_dtls_connection_get_interaction (GDtlsConnection *conn);
  103. GLIB_AVAILABLE_IN_2_48
  104. GTlsCertificate *g_dtls_connection_get_peer_certificate (GDtlsConnection *conn);
  105. GLIB_AVAILABLE_IN_2_48
  106. GTlsCertificateFlags g_dtls_connection_get_peer_certificate_errors (GDtlsConnection *conn);
  107. GLIB_AVAILABLE_IN_2_48
  108. void g_dtls_connection_set_require_close_notify (GDtlsConnection *conn,
  109. gboolean require_close_notify);
  110. GLIB_AVAILABLE_IN_2_48
  111. gboolean g_dtls_connection_get_require_close_notify (GDtlsConnection *conn);
  112. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  113. GLIB_DEPRECATED_IN_2_60
  114. void g_dtls_connection_set_rehandshake_mode (GDtlsConnection *conn,
  115. GTlsRehandshakeMode mode);
  116. GLIB_DEPRECATED_IN_2_60
  117. GTlsRehandshakeMode g_dtls_connection_get_rehandshake_mode (GDtlsConnection *conn);
  118. G_GNUC_END_IGNORE_DEPRECATIONS
  119. GLIB_AVAILABLE_IN_2_48
  120. gboolean g_dtls_connection_handshake (GDtlsConnection *conn,
  121. GCancellable *cancellable,
  122. GError **error);
  123. GLIB_AVAILABLE_IN_2_48
  124. void g_dtls_connection_handshake_async (GDtlsConnection *conn,
  125. int io_priority,
  126. GCancellable *cancellable,
  127. GAsyncReadyCallback callback,
  128. gpointer user_data);
  129. GLIB_AVAILABLE_IN_2_48
  130. gboolean g_dtls_connection_handshake_finish (GDtlsConnection *conn,
  131. GAsyncResult *result,
  132. GError **error);
  133. GLIB_AVAILABLE_IN_2_48
  134. gboolean g_dtls_connection_shutdown (GDtlsConnection *conn,
  135. gboolean shutdown_read,
  136. gboolean shutdown_write,
  137. GCancellable *cancellable,
  138. GError **error);
  139. GLIB_AVAILABLE_IN_2_48
  140. void g_dtls_connection_shutdown_async (GDtlsConnection *conn,
  141. gboolean shutdown_read,
  142. gboolean shutdown_write,
  143. int io_priority,
  144. GCancellable *cancellable,
  145. GAsyncReadyCallback callback,
  146. gpointer user_data);
  147. GLIB_AVAILABLE_IN_2_48
  148. gboolean g_dtls_connection_shutdown_finish (GDtlsConnection *conn,
  149. GAsyncResult *result,
  150. GError **error);
  151. GLIB_AVAILABLE_IN_2_48
  152. gboolean g_dtls_connection_close (GDtlsConnection *conn,
  153. GCancellable *cancellable,
  154. GError **error);
  155. GLIB_AVAILABLE_IN_2_48
  156. void g_dtls_connection_close_async (GDtlsConnection *conn,
  157. int io_priority,
  158. GCancellable *cancellable,
  159. GAsyncReadyCallback callback,
  160. gpointer user_data);
  161. GLIB_AVAILABLE_IN_2_48
  162. gboolean g_dtls_connection_close_finish (GDtlsConnection *conn,
  163. GAsyncResult *result,
  164. GError **error);
  165. /*< protected >*/
  166. GLIB_AVAILABLE_IN_2_48
  167. gboolean g_dtls_connection_emit_accept_certificate (GDtlsConnection *conn,
  168. GTlsCertificate *peer_cert,
  169. GTlsCertificateFlags errors);
  170. GLIB_AVAILABLE_IN_2_60
  171. void g_dtls_connection_set_advertised_protocols (GDtlsConnection *conn,
  172. const gchar * const *protocols);
  173. GLIB_AVAILABLE_IN_2_60
  174. const gchar * g_dtls_connection_get_negotiated_protocol (GDtlsConnection *conn);
  175. G_END_DECLS
  176. #endif /* __G_DTLS_CONNECTION_H__ */