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,
108 _NM_SETTING_PARSE_FLAGS_LAST,
109 NM_SETTING_PARSE_FLAGS_ALL = ((_NM_SETTING_PARSE_FLAGS_LAST - 1) << 1) - 1,
110 } NMSettingParseFlags;
112 gboolean _nm_connection_replace_settings (NMConnection *connection,
113 GVariant *new_settings,
114 NMSettingParseFlags parse_flags,
117 guint32 _nm_setting_get_setting_priority (NMSetting *setting);
119 gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
121 GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
123 GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
125 typedef gpointer (*NMUtilsCopyFunc) (gpointer);
127 GPtrArray *_nm_utils_copy_slist_to_array (const GSList *list,
128 NMUtilsCopyFunc copy_func,
129 GDestroyNotify unref_func);
130 GSList *_nm_utils_copy_array_to_slist (const GPtrArray *array,
131 NMUtilsCopyFunc copy_func);
133 GPtrArray *_nm_utils_copy_array (const GPtrArray *array,
134 NMUtilsCopyFunc copy_func,
135 GDestroyNotify free_func);
136 GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array);
138 gssize _nm_utils_ptrarray_find_first (gpointer *list, gssize len, gconstpointer needle);
140 gssize _nm_utils_ptrarray_find_binary_search (gpointer *list, gsize len, gpointer needle, GCompareDataFunc cmpfcn, gpointer user_data);
142 gboolean _nm_utils_string_in_list (const char *str,
143 const char **valid_strings);
145 gssize _nm_utils_strv_find_first (char **list, gssize len, const char *needle);
147 char **_nm_utils_strv_cleanup (char **strv,
148 gboolean strip_whitespace,
150 gboolean skip_repeated);
152 char ** _nm_utils_strsplit_set (const char *str,
153 const char *delimiters,
156 GSList * _nm_utils_strv_to_slist (char **strv, gboolean deep_copy);
157 char ** _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy);
159 GPtrArray * _nm_utils_strv_to_ptrarray (char **strv);
160 char ** _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray);
161 gboolean _nm_utils_strv_equal (char **strv1, char **strv2);
163 gboolean _nm_utils_check_file (const char *filename,
165 NMUtilsCheckFilePredicate check_file,
170 gboolean _nm_utils_check_module_file (const char *name,
172 NMUtilsCheckFilePredicate check_file,
176 #define NM_UTILS_UUID_TYPE_LEGACY 0
177 #define NM_UTILS_UUID_TYPE_VARIANT3 1
179 char *nm_utils_uuid_generate_from_string (const char *s, gssize slen, int uuid_type, gpointer type_args);
181 /* arbitrarily choosen namespace UUID for _nm_utils_uuid_generate_from_strings() */
182 #define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
184 char *_nm_utils_uuid_generate_from_strings (const char *string1, ...) G_GNUC_NULL_TERMINATED;
186 void _nm_dbus_errors_init (void);
188 extern gboolean _nm_utils_is_manager_process;
190 GByteArray *nm_utils_rsa_key_encrypt (const guint8 *data,
192 const char *in_password,
196 gulong _nm_dbus_signal_connect_data (GDBusProxy *proxy,
197 const char *signal_name,
198 const GVariantType *signature,
201 GClosureNotify destroy_data,
202 GConnectFlags connect_flags);
203 #define _nm_dbus_signal_connect(proxy, name, signature, handler, data) \
204 _nm_dbus_signal_connect_data (proxy, name, signature, handler, data, NULL, (GConnectFlags) 0)
206 GVariant *_nm_dbus_proxy_call_finish (GDBusProxy *proxy,
208 const GVariantType *reply_type,
211 GVariant *_nm_dbus_proxy_call_sync (GDBusProxy *proxy,
212 const gchar *method_name,
213 GVariant *parameters,
214 const GVariantType *reply_type,
215 GDBusCallFlags flags,
217 GCancellable *cancellable,
220 gboolean _nm_dbus_error_has_name (GError *error,
221 const char *dbus_error_name);
223 /***********************************************************/
225 gboolean _nm_vpn_plugin_info_check_file (const char *filename,
226 gboolean check_absolute,
227 gboolean do_validate_filename,
229 NMUtilsCheckFilePredicate check_file,
233 const char *_nm_vpn_plugin_info_get_default_dir_etc (void);
234 const char *_nm_vpn_plugin_info_get_default_dir_lib (void);
235 const char *_nm_vpn_plugin_info_get_default_dir_user (void);
237 GSList *_nm_vpn_plugin_info_list_load_dir (const char *dirname,
238 gboolean do_validate_filename,
240 NMUtilsCheckFilePredicate check_file,
243 /***********************************************************/
249 } NMUtilsDNSOptionDesc;
251 extern const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[];
253 gboolean _nm_utils_dns_option_validate (const char *option, char **out_name,
254 long *out_value, gboolean ipv6,
255 const NMUtilsDNSOptionDesc *option_descs);
256 int _nm_utils_dns_option_find_idx (GPtrArray *array, const char *option);
258 /***********************************************************/
260 typedef struct _NMUtilsStrStrDictKey NMUtilsStrStrDictKey;
261 guint _nm_utils_strstrdictkey_hash (gconstpointer a);
262 gboolean _nm_utils_strstrdictkey_equal (gconstpointer a, gconstpointer b);
263 NMUtilsStrStrDictKey *_nm_utils_strstrdictkey_create (const char *v1, const char *v2);
265 #define _nm_utils_strstrdictkey_static(v1, v2) \
266 ( (NMUtilsStrStrDictKey *) ("\03" v1 "\0" v2 "") )
268 /***********************************************************/
270 gboolean _nm_setting_vlan_set_priorities (NMSettingVlan *setting,
271 NMVlanPriorityMap map,
272 const NMVlanQosMapping *qos_map,
274 void _nm_setting_vlan_get_priorities (NMSettingVlan *setting,
275 NMVlanPriorityMap map,
276 NMVlanQosMapping **out_qos_map,
277 guint *out_n_qos_map);
279 /***********************************************************/