Branch data Line data Source code
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 : :
22 : : #include "config.h"
23 : : #include "glib.h"
24 : :
25 : : #include "gdtlsserverconnection.h"
26 : : #include "ginitable.h"
27 : : #include "gioenumtypes.h"
28 : : #include "gsocket.h"
29 : : #include "gtlsbackend.h"
30 : : #include "gtlscertificate.h"
31 : : #include "glibintl.h"
32 : :
33 : : /**
34 : : * GDtlsServerConnection:
35 : : *
36 : : * `GDtlsServerConnection` is the server-side subclass of
37 : : * [iface@Gio.DtlsConnection], representing a server-side DTLS connection.
38 : : *
39 : : * Since: 2.48
40 : : */
41 : 2 : G_DEFINE_INTERFACE (GDtlsServerConnection, g_dtls_server_connection,
42 : : G_TYPE_DTLS_CONNECTION)
43 : :
44 : : static void
45 : 1 : g_dtls_server_connection_default_init (GDtlsServerConnectionInterface *iface)
46 : : {
47 : : /**
48 : : * GDtlsServerConnection:authentication-mode:
49 : : *
50 : : * The #GTlsAuthenticationMode for the server. This can be changed
51 : : * before calling g_dtls_connection_handshake() if you want to
52 : : * rehandshake with a different mode from the initial handshake.
53 : : *
54 : : * Since: 2.48
55 : : */
56 : 1 : g_object_interface_install_property (iface,
57 : : g_param_spec_enum ("authentication-mode", NULL, NULL,
58 : : G_TYPE_TLS_AUTHENTICATION_MODE,
59 : : G_TLS_AUTHENTICATION_NONE,
60 : : G_PARAM_READWRITE |
61 : : G_PARAM_STATIC_STRINGS));
62 : 1 : }
63 : :
64 : : /**
65 : : * g_dtls_server_connection_new:
66 : : * @base_socket: the #GDatagramBased to wrap
67 : : * @certificate: (nullable): the default server certificate, or %NULL
68 : : * @error: #GError for error reporting, or %NULL to ignore
69 : : *
70 : : * Creates a new #GDtlsServerConnection wrapping @base_socket.
71 : : *
72 : : * Returns: (transfer full) (type GDtlsServerConnection): the new
73 : : * #GDtlsServerConnection, or %NULL on error
74 : : *
75 : : * Since: 2.48
76 : : */
77 : : GDatagramBased *
78 : 0 : g_dtls_server_connection_new (GDatagramBased *base_socket,
79 : : GTlsCertificate *certificate,
80 : : GError **error)
81 : : {
82 : : GObject *conn;
83 : : GTlsBackend *backend;
84 : :
85 : 0 : backend = g_tls_backend_get_default ();
86 : 0 : conn = g_initable_new (g_tls_backend_get_dtls_server_connection_type (backend),
87 : : NULL, error,
88 : : "base-socket", base_socket,
89 : : "certificate", certificate,
90 : : NULL);
91 : 0 : return G_DATAGRAM_BASED (conn);
92 : : }
|