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 typedef enum { /*< skip >*/
104 NM_SETTING_PARSE_FLAGS_NONE = 0,
105 NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
106 NM_SETTING_PARSE_FLAGS_BEST_EFFORT = 1LL << 1,
107 NM_SETTING_PARSE_FLAGS_NORMALIZE = 1LL << 2,
109 _NM_SETTING_PARSE_FLAGS_LAST,
110 NM_SETTING_PARSE_FLAGS_ALL = ((_NM_SETTING_PARSE_FLAGS_LAST - 1) << 1) - 1,
111 } NMSettingParseFlags;
113 gboolean _nm_connection_replace_settings (NMConnection *connection,
114 GVariant *new_settings,
115 NMSettingParseFlags parse_flags,
118 NMConnection *_nm_simple_connection_new_from_dbus (GVariant *dict,
119 NMSettingParseFlags parse_flags,
122 guint32 _nm_setting_get_setting_priority (NMSetting *setting);
124 gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
126 GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
128 GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
130 typedef gpointer (*NMUtilsCopyFunc) (gpointer);
132 GPtrArray *_nm_utils_copy_slist_to_array (const GSList *list,
133 NMUtilsCopyFunc copy_func,
134 GDestroyNotify unref_func);
135 GSList *_nm_utils_copy_array_to_slist (const GPtrArray *array,
136 NMUtilsCopyFunc copy_func);
138 GPtrArray *_nm_utils_copy_array (const GPtrArray *array,
139 NMUtilsCopyFunc copy_func,
140 GDestroyNotify free_func);
141 GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array);
143 gssize _nm_utils_ptrarray_find_first (gpointer *list, gssize len, gconstpointer needle);
145 gssize _nm_utils_ptrarray_find_binary_search (gpointer *list, gsize len, gpointer needle, GCompareDataFunc cmpfcn, gpointer user_data);
147 gboolean _nm_utils_string_in_list (const char *str,
148 const char **valid_strings);
150 gssize _nm_utils_strv_find_first (char **list, gssize len, const char *needle);
152 char **_nm_utils_strv_cleanup (char **strv,
153 gboolean strip_whitespace,
155 gboolean skip_repeated);
157 char ** _nm_utils_strsplit_set (const char *str,
158 const char *delimiters,
161 GSList * _nm_utils_strv_to_slist (char **strv, gboolean deep_copy);
162 char ** _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy);
164 GPtrArray * _nm_utils_strv_to_ptrarray (char **strv);
165 char ** _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray);
166 gboolean _nm_utils_strv_equal (char **strv1, char **strv2);
168 gboolean _nm_utils_check_file (const char *filename,
170 NMUtilsCheckFilePredicate check_file,
175 gboolean _nm_utils_check_module_file (const char *name,
177 NMUtilsCheckFilePredicate check_file,
181 #define NM_UTILS_UUID_TYPE_LEGACY 0
182 #define NM_UTILS_UUID_TYPE_VARIANT3 1
184 char *nm_utils_uuid_generate_from_string (const char *s, gssize slen, int uuid_type, gpointer type_args);
186 /* arbitrarily choosen namespace UUID for _nm_utils_uuid_generate_from_strings() */
187 #define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
189 char *_nm_utils_uuid_generate_from_strings (const char *string1, ...) G_GNUC_NULL_TERMINATED;
191 void _nm_dbus_errors_init (void);
193 extern gboolean _nm_utils_is_manager_process;
195 GByteArray *nm_utils_rsa_key_encrypt (const guint8 *data,
197 const char *in_password,
201 gulong _nm_dbus_signal_connect_data (GDBusProxy *proxy,
202 const char *signal_name,
203 const GVariantType *signature,
206 GClosureNotify destroy_data,
207 GConnectFlags connect_flags);
208 #define _nm_dbus_signal_connect(proxy, name, signature, handler, data) \
209 _nm_dbus_signal_connect_data (proxy, name, signature, handler, data, NULL, (GConnectFlags) 0)
211 GVariant *_nm_dbus_proxy_call_finish (GDBusProxy *proxy,
213 const GVariantType *reply_type,
216 GVariant *_nm_dbus_proxy_call_sync (GDBusProxy *proxy,
217 const gchar *method_name,
218 GVariant *parameters,
219 const GVariantType *reply_type,
220 GDBusCallFlags flags,
222 GCancellable *cancellable,
225 gboolean _nm_dbus_error_has_name (GError *error,
226 const char *dbus_error_name);
228 /***********************************************************/
230 gboolean _nm_vpn_plugin_info_check_file (const char *filename,
231 gboolean check_absolute,
232 gboolean do_validate_filename,
234 NMUtilsCheckFilePredicate check_file,
238 const char *_nm_vpn_plugin_info_get_default_dir_etc (void);
239 const char *_nm_vpn_plugin_info_get_default_dir_lib (void);
240 const char *_nm_vpn_plugin_info_get_default_dir_user (void);
242 GSList *_nm_vpn_plugin_info_list_load_dir (const char *dirname,
243 gboolean do_validate_filename,
245 NMUtilsCheckFilePredicate check_file,
248 /***********************************************************/
254 } NMUtilsDNSOptionDesc;
256 extern const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[];
258 gboolean _nm_utils_dns_option_validate (const char *option, char **out_name,
259 long *out_value, gboolean ipv6,
260 const NMUtilsDNSOptionDesc *option_descs);
261 int _nm_utils_dns_option_find_idx (GPtrArray *array, const char *option);
263 /***********************************************************/
265 typedef struct _NMUtilsStrStrDictKey NMUtilsStrStrDictKey;
266 guint _nm_utils_strstrdictkey_hash (gconstpointer a);
267 gboolean _nm_utils_strstrdictkey_equal (gconstpointer a, gconstpointer b);
268 NMUtilsStrStrDictKey *_nm_utils_strstrdictkey_create (const char *v1, const char *v2);
270 #define _nm_utils_strstrdictkey_static(v1, v2) \
271 ( (NMUtilsStrStrDictKey *) ("\03" v1 "\0" v2 "") )
273 /***********************************************************/
275 gboolean _nm_setting_vlan_set_priorities (NMSettingVlan *setting,
276 NMVlanPriorityMap map,
277 const NMVlanQosMapping *qos_map,
279 void _nm_setting_vlan_get_priorities (NMSettingVlan *setting,
280 NMVlanPriorityMap map,
281 NMVlanQosMapping **out_qos_map,
282 guint *out_n_qos_map);
284 /***********************************************************/
287 NM_BOND_OPTION_TYPE_INT,
288 NM_BOND_OPTION_TYPE_STRING,
289 NM_BOND_OPTION_TYPE_BOTH,
290 NM_BOND_OPTION_TYPE_IP,
291 NM_BOND_OPTION_TYPE_IFNAME,
295 _nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name);