1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA.
19 * (C) Copyright 2014 Red Hat, Inc.
22 #ifndef NM_CORE_NM_INTERNAL_H
23 #define NM_CORE_NM_INTERNAL_H
25 /* This header file contain functions that are provided as private API
26 * by libnm-core. It will contain functions to give privileged access to
27 * libnm-core. This can be useful for NetworkManager and libnm.so
28 * which both are special users of libnm-core.
29 * It also exposes some utility functions for reuse.
31 * These functions are not exported and are only available to components that link
32 * statically against libnm-core. This basically means libnm-core, libnm, NetworkManager
33 * and some test programs.
37 #include "nm-default.h"
38 #include "nm-connection.h"
39 #include "nm-core-enum-types.h"
40 #include "nm-setting-8021x.h"
41 #include "nm-setting-adsl.h"
42 #include "nm-setting-bluetooth.h"
43 #include "nm-setting-bond.h"
44 #include "nm-setting-bridge-port.h"
45 #include "nm-setting-bridge.h"
46 #include "nm-setting-cdma.h"
47 #include "nm-setting-connection.h"
48 #include "nm-setting-dcb.h"
49 #include "nm-setting-generic.h"
50 #include "nm-setting-gsm.h"
51 #include "nm-setting-infiniband.h"
52 #include "nm-setting-ip-tunnel.h"
53 #include "nm-setting-ip4-config.h"
54 #include "nm-setting-ip6-config.h"
55 #include "nm-setting-macvlan.h"
56 #include "nm-setting-olpc-mesh.h"
57 #include "nm-setting-ppp.h"
58 #include "nm-setting-pppoe.h"
59 #include "nm-setting-serial.h"
60 #include "nm-setting-team-port.h"
61 #include "nm-setting-team.h"
62 #include "nm-setting-tun.h"
63 #include "nm-setting-vlan.h"
64 #include "nm-setting-vpn.h"
65 #include "nm-setting-vxlan.h"
66 #include "nm-setting-wimax.h"
67 #include "nm-setting-wired.h"
68 #include "nm-setting-wireless-security.h"
69 #include "nm-setting-wireless.h"
70 #include "nm-setting.h"
71 #include "nm-simple-connection.h"
73 #include "nm-vpn-dbus-interface.h"
74 #include "nm-core-types-internal.h"
76 /* NM_SETTING_COMPARE_FLAG_INFERRABLE: check whether a device-generated
77 * connection can be replaced by a already-defined connection. This flag only
78 * takes into account properties marked with the %NM_SETTING_PARAM_INFERRABLE
81 #define NM_SETTING_COMPARE_FLAG_INFERRABLE ((NMSettingCompareFlags) 0x80000000)
83 /* NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY: this flag is used for properties
84 * that automatically get re-applied on an active connection when the settings
85 * connection is modified. For most properties, the applied-connection is distinct
86 * from the setting-connection and changes don't propagate. Exceptions are the
87 * firewall-zone and the metered property.
89 #define NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY ((NMSettingCompareFlags) 0x40000000)
91 /* NM_SETTING_COMPARE_FLAG_NONE: for convenience, define a special flag NONE -- which
92 * equals to numeric zero (NM_SETTING_COMPARE_FLAG_EXACT).
94 #define NM_SETTING_COMPARE_FLAG_NONE ((NMSettingCompareFlags) 0)
97 #define NM_SETTING_SECRET_FLAGS_ALL \
98 (NM_SETTING_SECRET_FLAG_NONE | \
99 NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
100 NM_SETTING_SECRET_FLAG_NOT_SAVED | \
101 NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
103 guint32 _nm_setting_get_setting_priority (NMSetting *setting);
105 gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
107 GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
109 GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
111 typedef gpointer (*NMUtilsCopyFunc) (gpointer);
113 GPtrArray *_nm_utils_copy_slist_to_array (const GSList *list,
114 NMUtilsCopyFunc copy_func,
115 GDestroyNotify unref_func);
116 GSList *_nm_utils_copy_array_to_slist (const GPtrArray *array,
117 NMUtilsCopyFunc copy_func);
119 GPtrArray *_nm_utils_copy_array (const GPtrArray *array,
120 NMUtilsCopyFunc copy_func,
121 GDestroyNotify free_func);
122 GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array);
124 gssize _nm_utils_ptrarray_find_first (gpointer *list, gssize len, gconstpointer needle);
126 gssize _nm_utils_ptrarray_find_binary_search (gpointer *list, gsize len, gpointer needle, GCompareDataFunc cmpfcn, gpointer user_data);
128 gboolean _nm_utils_string_in_list (const char *str,
129 const char **valid_strings);
131 gssize _nm_utils_strv_find_first (char **list, gssize len, const char *needle);
133 char **_nm_utils_strv_cleanup (char **strv,
134 gboolean strip_whitespace,
136 gboolean skip_repeated);
138 char ** _nm_utils_strsplit_set (const char *str,
139 const char *delimiters,
142 GSList * _nm_utils_strv_to_slist (char **strv, gboolean deep_copy);
143 char ** _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy);
145 GPtrArray * _nm_utils_strv_to_ptrarray (char **strv);
146 char ** _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray);
147 gboolean _nm_utils_strv_equal (char **strv1, char **strv2);
149 gboolean _nm_utils_check_file (const char *filename,
151 NMUtilsCheckFilePredicate check_file,
156 gboolean _nm_utils_check_module_file (const char *name,
158 NMUtilsCheckFilePredicate check_file,
162 #define NM_UTILS_UUID_TYPE_LEGACY 0
163 #define NM_UTILS_UUID_TYPE_VARIANT3 1
165 char *nm_utils_uuid_generate_from_string (const char *s, gssize slen, int uuid_type, gpointer type_args);
167 /* arbitrarily choosen namespace UUID for _nm_utils_uuid_generate_from_strings() */
168 #define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
170 char *_nm_utils_uuid_generate_from_strings (const char *string1, ...) G_GNUC_NULL_TERMINATED;
172 void _nm_dbus_errors_init (void);
174 extern gboolean _nm_utils_is_manager_process;
176 GByteArray *nm_utils_rsa_key_encrypt (const guint8 *data,
178 const char *in_password,
182 gulong _nm_dbus_signal_connect_data (GDBusProxy *proxy,
183 const char *signal_name,
184 const GVariantType *signature,
187 GClosureNotify destroy_data,
188 GConnectFlags connect_flags);
189 #define _nm_dbus_signal_connect(proxy, name, signature, handler, data) \
190 _nm_dbus_signal_connect_data (proxy, name, signature, handler, data, NULL, (GConnectFlags) 0)
192 GVariant *_nm_dbus_proxy_call_finish (GDBusProxy *proxy,
194 const GVariantType *reply_type,
197 GVariant *_nm_dbus_proxy_call_sync (GDBusProxy *proxy,
198 const gchar *method_name,
199 GVariant *parameters,
200 const GVariantType *reply_type,
201 GDBusCallFlags flags,
203 GCancellable *cancellable,
206 gboolean _nm_dbus_error_has_name (GError *error,
207 const char *dbus_error_name);
209 /***********************************************************/
211 gboolean _nm_vpn_plugin_info_check_file (const char *filename,
212 gboolean check_absolute,
213 gboolean do_validate_filename,
215 NMUtilsCheckFilePredicate check_file,
219 const char *_nm_vpn_plugin_info_get_default_dir_etc (void);
220 const char *_nm_vpn_plugin_info_get_default_dir_lib (void);
221 const char *_nm_vpn_plugin_info_get_default_dir_user (void);
223 GSList *_nm_vpn_plugin_info_list_load_dir (const char *dirname,
224 gboolean do_validate_filename,
226 NMUtilsCheckFilePredicate check_file,
229 /***********************************************************/
235 } NMUtilsDNSOptionDesc;
237 extern const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[];
239 gboolean _nm_utils_dns_option_validate (const char *option, char **out_name,
240 long *out_value, gboolean ipv6,
241 const NMUtilsDNSOptionDesc *option_descs);
242 int _nm_utils_dns_option_find_idx (GPtrArray *array, const char *option);
244 /***********************************************************/
246 typedef struct _NMUtilsStrStrDictKey NMUtilsStrStrDictKey;
247 guint _nm_utils_strstrdictkey_hash (gconstpointer a);
248 gboolean _nm_utils_strstrdictkey_equal (gconstpointer a, gconstpointer b);
249 NMUtilsStrStrDictKey *_nm_utils_strstrdictkey_create (const char *v1, const char *v2);
251 #define _nm_utils_strstrdictkey_static(v1, v2) \
252 ( (NMUtilsStrStrDictKey *) ("\03" v1 "\0" v2 "") )
254 /***********************************************************/
256 gboolean _nm_setting_vlan_set_priorities (NMSettingVlan *setting,
257 NMVlanPriorityMap map,
258 const NMVlanQosMapping *qos_map,
260 void _nm_setting_vlan_get_priorities (NMSettingVlan *setting,
261 NMVlanPriorityMap map,
262 NMVlanQosMapping **out_qos_map,
263 guint *out_n_qos_map);
265 /***********************************************************/