gdtlsconnection.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 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. *
  42. * Virtual method table for a #GDtlsConnection implementation.
  43. *
  44. * Since: 2.48
  45. */
  46. struct _GDtlsConnectionInterface
  47. {
  48. GTypeInterface g_iface;
  49. /* signals */
  50. gboolean (*accept_certificate) (GDtlsConnection *connection,
  51. GTlsCertificate *peer_cert,
  52. GTlsCertificateFlags errors);
  53. /* methods */
  54. gboolean (*handshake) (GDtlsConnection *conn,
  55. GCancellable *cancellable,
  56. GError **error);
  57. void (*handshake_async) (GDtlsConnection *conn,
  58. int io_priority,
  59. GCancellable *cancellable,
  60. GAsyncReadyCallback callback,
  61. gpointer user_data);
  62. gboolean (*handshake_finish) (GDtlsConnection *conn,
  63. GAsyncResult *result,
  64. GError **error);
  65. gboolean (*shutdown) (GDtlsConnection *conn,
  66. gboolean shutdown_read,
  67. gboolean shutdown_write,
  68. GCancellable *cancellable,
  69. GError **error);
  70. void (*shutdown_async) (GDtlsConnection *conn,
  71. gboolean shutdown_read,
  72. gboolean shutdown_write,
  73. int io_priority,
  74. GCancellable *cancellable,
  75. GAsyncReadyCallback callback,
  76. gpointer user_data);
  77. gboolean (*shutdown_finish) (GDtlsConnection *conn,
  78. GAsyncResult *result,
  79. GError **error);
  80. };
  81. GLIB_AVAILABLE_IN_2_48
  82. GType g_dtls_connection_get_type (void) G_GNUC_CONST;
  83. GLIB_AVAILABLE_IN_2_48
  84. void g_dtls_connection_set_database (GDtlsConnection *conn,
  85. GTlsDatabase *database);
  86. GLIB_AVAILABLE_IN_2_48
  87. GTlsDatabase *g_dtls_connection_get_database (GDtlsConnection *conn);
  88. GLIB_AVAILABLE_IN_2_48
  89. void g_dtls_connection_set_certificate (GDtlsConnection *conn,
  90. GTlsCertificate *certificate);
  91. GLIB_AVAILABLE_IN_2_48
  92. GTlsCertificate *g_dtls_connection_get_certificate (GDtlsConnection *conn);
  93. GLIB_AVAILABLE_IN_2_48
  94. void g_dtls_connection_set_interaction (GDtlsConnection *conn,
  95. GTlsInteraction *interaction);
  96. GLIB_AVAILABLE_IN_2_48
  97. GTlsInteraction *g_dtls_connection_get_interaction (GDtlsConnection *conn);
  98. GLIB_AVAILABLE_IN_2_48
  99. GTlsCertificate *g_dtls_connection_get_peer_certificate (GDtlsConnection *conn);
  100. GLIB_AVAILABLE_IN_2_48
  101. GTlsCertificateFlags g_dtls_connection_get_peer_certificate_errors (GDtlsConnection *conn);
  102. GLIB_AVAILABLE_IN_2_48
  103. void g_dtls_connection_set_require_close_notify (GDtlsConnection *conn,
  104. gboolean require_close_notify);
  105. GLIB_AVAILABLE_IN_2_48
  106. gboolean g_dtls_connection_get_require_close_notify (GDtlsConnection *conn);
  107. GLIB_AVAILABLE_IN_2_48
  108. void g_dtls_connection_set_rehandshake_mode (GDtlsConnection *conn,
  109. GTlsRehandshakeMode mode);
  110. GLIB_AVAILABLE_IN_2_48
  111. GTlsRehandshakeMode g_dtls_connection_get_rehandshake_mode (GDtlsConnection *conn);
  112. GLIB_AVAILABLE_IN_2_48
  113. gboolean g_dtls_connection_handshake (GDtlsConnection *conn,
  114. GCancellable *cancellable,
  115. GError **error);
  116. GLIB_AVAILABLE_IN_2_48
  117. void g_dtls_connection_handshake_async (GDtlsConnection *conn,
  118. int io_priority,
  119. GCancellable *cancellable,
  120. GAsyncReadyCallback callback,
  121. gpointer user_data);
  122. GLIB_AVAILABLE_IN_2_48
  123. gboolean g_dtls_connection_handshake_finish (GDtlsConnection *conn,
  124. GAsyncResult *result,
  125. GError **error);
  126. GLIB_AVAILABLE_IN_2_48
  127. gboolean g_dtls_connection_shutdown (GDtlsConnection *conn,
  128. gboolean shutdown_read,
  129. gboolean shutdown_write,
  130. GCancellable *cancellable,
  131. GError **error);
  132. GLIB_AVAILABLE_IN_2_48
  133. void g_dtls_connection_shutdown_async (GDtlsConnection *conn,
  134. gboolean shutdown_read,
  135. gboolean shutdown_write,
  136. int io_priority,
  137. GCancellable *cancellable,
  138. GAsyncReadyCallback callback,
  139. gpointer user_data);
  140. GLIB_AVAILABLE_IN_2_48
  141. gboolean g_dtls_connection_shutdown_finish (GDtlsConnection *conn,
  142. GAsyncResult *result,
  143. GError **error);
  144. GLIB_AVAILABLE_IN_2_48
  145. gboolean g_dtls_connection_close (GDtlsConnection *conn,
  146. GCancellable *cancellable,
  147. GError **error);
  148. GLIB_AVAILABLE_IN_2_48
  149. void g_dtls_connection_close_async (GDtlsConnection *conn,
  150. int io_priority,
  151. GCancellable *cancellable,
  152. GAsyncReadyCallback callback,
  153. gpointer user_data);
  154. GLIB_AVAILABLE_IN_2_48
  155. gboolean g_dtls_connection_close_finish (GDtlsConnection *conn,
  156. GAsyncResult *result,
  157. GError **error);
  158. /*< protected >*/
  159. GLIB_AVAILABLE_IN_2_48
  160. gboolean g_dtls_connection_emit_accept_certificate (GDtlsConnection *conn,
  161. GTlsCertificate *peer_cert,
  162. GTlsCertificateFlags errors);
  163. G_END_DECLS
  164. #endif /* __G_DTLS_CONNECTION_H__ */