1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
2 | /* |
3 | * Copyright (C) 2007 - 2008 Novell, Inc. |
4 | * Copyright (C) 2007 - 2015 Red Hat, Inc. |
5 | */ |
6 | |
7 | #ifndef __NM_VPN_SERVICE_PLUGIN_H__ |
8 | #define __NM_VPN_SERVICE_PLUGIN_H__ |
9 | |
10 | #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) |
11 | #error "Only <NetworkManager.h> can be included directly." |
12 | #endif |
13 | |
14 | #include <gio/gio.h> |
15 | #include "nm-vpn-dbus-interface.h" |
16 | #include "nm-connection.h" |
17 | |
18 | G_BEGIN_DECLS |
19 | |
20 | #define NM_TYPE_VPN_SERVICE_PLUGIN (nm_vpn_service_plugin_get_type()) |
21 | #define NM_VPN_SERVICE_PLUGIN(obj) \ |
22 | (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePlugin)) |
23 | #define NM_VPN_SERVICE_PLUGIN_CLASS(klass) \ |
24 | (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePluginClass)) |
25 | #define NM_IS_VPN_SERVICE_PLUGIN(obj) \ |
26 | (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_VPN_SERVICE_PLUGIN)) |
27 | #define NM_IS_VPN_SERVICE_PLUGIN_CLASS(klass) \ |
28 | (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_VPN_SERVICE_PLUGIN)) |
29 | #define NM_VPN_SERVICE_PLUGIN_GET_CLASS(obj) \ |
30 | (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePluginClass)) |
31 | |
32 | #define NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME "service-name" |
33 | #define NM_VPN_SERVICE_PLUGIN_DBUS_WATCH_PEER "watch-peer" |
34 | #define NM_VPN_SERVICE_PLUGIN_STATE "state" |
35 | |
36 | /** |
37 | * NMVpnServicePlugin: |
38 | */ |
39 | typedef struct { |
40 | NM_AVAILABLE_IN_1_2 |
41 | GObject parent; |
42 | } NMVpnServicePlugin NM_AVAILABLE_IN_1_2; |
43 | |
44 | typedef struct { |
45 | NM_AVAILABLE_IN_1_2 |
46 | GObjectClass parent; |
47 | |
48 | /* Signals */ |
49 | NM_AVAILABLE_IN_1_2 |
50 | void (*state_changed)(NMVpnServicePlugin *plugin, NMVpnServiceState state); |
51 | |
52 | NM_AVAILABLE_IN_1_2 |
53 | void (*ip4_config)(NMVpnServicePlugin *plugin, GVariant *ip4_config); |
54 | |
55 | NM_AVAILABLE_IN_1_2 |
56 | void (*login_banner)(NMVpnServicePlugin *plugin, const char *banner); |
57 | |
58 | NM_AVAILABLE_IN_1_2 |
59 | void (*failure)(NMVpnServicePlugin *plugin, NMVpnPluginFailure reason); |
60 | |
61 | NM_AVAILABLE_IN_1_2 |
62 | void (*quit)(NMVpnServicePlugin *plugin); |
63 | |
64 | NM_AVAILABLE_IN_1_2 |
65 | void (*config)(NMVpnServicePlugin *plugin, GVariant *config); |
66 | |
67 | NM_AVAILABLE_IN_1_2 |
68 | void (*ip6_config)(NMVpnServicePlugin *plugin, GVariant *config); |
69 | |
70 | /* virtual methods */ |
71 | NM_AVAILABLE_IN_1_2 |
72 | gboolean (*connect)(NMVpnServicePlugin *plugin, NMConnection *connection, GError **err); |
73 | |
74 | NM_AVAILABLE_IN_1_2 |
75 | gboolean (*need_secrets)(NMVpnServicePlugin *plugin, |
76 | NMConnection *connection, |
77 | const char **setting_name, |
78 | GError **error); |
79 | |
80 | NM_AVAILABLE_IN_1_2 |
81 | gboolean (*disconnect)(NMVpnServicePlugin *plugin, GError **err); |
82 | |
83 | NM_AVAILABLE_IN_1_2 |
84 | gboolean (*new_secrets)(NMVpnServicePlugin *plugin, NMConnection *connection, GError **error); |
85 | |
86 | NM_AVAILABLE_IN_1_2 |
87 | gboolean (*connect_interactive)(NMVpnServicePlugin *plugin, |
88 | NMConnection *connection, |
89 | GVariant *details, |
90 | GError **error); |
91 | |
92 | /*< private >*/ |
93 | NM_AVAILABLE_IN_1_2 |
94 | gpointer padding[8]; |
95 | } NMVpnServicePluginClass NM_AVAILABLE_IN_1_2; |
96 | |
97 | NM_AVAILABLE_IN_1_2 |
98 | GType nm_vpn_service_plugin_get_type(void); |
99 | |
100 | NM_AVAILABLE_IN_1_2 |
101 | GDBusConnection *nm_vpn_service_plugin_get_connection(NMVpnServicePlugin *plugin); |
102 | |
103 | NM_AVAILABLE_IN_1_2 |
104 | void nm_vpn_service_plugin_secrets_required(NMVpnServicePlugin *plugin, |
105 | const char *message, |
106 | const char **hints); |
107 | |
108 | NM_AVAILABLE_IN_1_2 |
109 | void nm_vpn_service_plugin_set_login_banner(NMVpnServicePlugin *plugin, const char *banner); |
110 | |
111 | NM_AVAILABLE_IN_1_2 |
112 | void nm_vpn_service_plugin_failure(NMVpnServicePlugin *plugin, NMVpnPluginFailure reason); |
113 | |
114 | NM_AVAILABLE_IN_1_2 |
115 | void nm_vpn_service_plugin_set_config(NMVpnServicePlugin *plugin, GVariant *config); |
116 | |
117 | NM_AVAILABLE_IN_1_2 |
118 | void nm_vpn_service_plugin_set_ip4_config(NMVpnServicePlugin *plugin, GVariant *ip4_config); |
119 | |
120 | NM_AVAILABLE_IN_1_2 |
121 | void nm_vpn_service_plugin_set_ip6_config(NMVpnServicePlugin *plugin, GVariant *ip6_config); |
122 | |
123 | NM_AVAILABLE_IN_1_2 |
124 | gboolean nm_vpn_service_plugin_disconnect(NMVpnServicePlugin *plugin, GError **err); |
125 | |
126 | NM_AVAILABLE_IN_1_12 |
127 | void nm_vpn_service_plugin_shutdown(NMVpnServicePlugin *plugin); |
128 | |
129 | /* Utility functions */ |
130 | |
131 | NM_AVAILABLE_IN_1_2 |
132 | gboolean |
133 | nm_vpn_service_plugin_read_vpn_details(int fd, GHashTable **out_data, GHashTable **out_secrets); |
134 | |
135 | NM_AVAILABLE_IN_1_2 |
136 | gboolean nm_vpn_service_plugin_get_secret_flags(GHashTable *data, |
137 | const char *secret_name, |
138 | NMSettingSecretFlags *out_flags); |
139 | |
140 | G_END_DECLS |
141 | |
142 | #endif /* __NM_VPN_SERVICE_PLUGIN_H__ */ |
143 | |