nm-core-internal.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
  2. /*
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the
  15. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. * Boston, MA 02110-1301 USA.
  17. *
  18. * (C) Copyright 2014 - 2018 Red Hat, Inc.
  19. */
  20. #ifndef NM_CORE_NM_INTERNAL_H
  21. #define NM_CORE_NM_INTERNAL_H
  22. /* This header file contain functions that are provided as private API
  23. * by libnm-core. It will contain functions to give privileged access to
  24. * libnm-core. This can be useful for NetworkManager and libnm.so
  25. * which both are special users of libnm-core.
  26. * It also exposes some utility functions for reuse.
  27. *
  28. * These functions are not exported and are only available to components that link
  29. * statically against libnm-core. This basically means libnm-core, libnm, NetworkManager
  30. * and some test programs.
  31. **/
  32. #if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL)
  33. #error Cannot use this header.
  34. #endif
  35. #include "nm-connection.h"
  36. #include "nm-core-enum-types.h"
  37. #include "nm-setting-6lowpan.h"
  38. #include "nm-setting-8021x.h"
  39. #include "nm-setting-adsl.h"
  40. #include "nm-setting-bluetooth.h"
  41. #include "nm-setting-bond.h"
  42. #include "nm-setting-bridge-port.h"
  43. #include "nm-setting-bridge.h"
  44. #include "nm-setting-cdma.h"
  45. #include "nm-setting-connection.h"
  46. #include "nm-setting-dcb.h"
  47. #include "nm-setting-dummy.h"
  48. #include "nm-setting-generic.h"
  49. #include "nm-setting-gsm.h"
  50. #include "nm-setting-infiniband.h"
  51. #include "nm-setting-ip-tunnel.h"
  52. #include "nm-setting-proxy.h"
  53. #include "nm-setting-ip4-config.h"
  54. #include "nm-setting-ip6-config.h"
  55. #include "nm-setting-macsec.h"
  56. #include "nm-setting-macvlan.h"
  57. #include "nm-setting-match.h"
  58. #include "nm-setting-olpc-mesh.h"
  59. #include "nm-setting-ovs-bridge.h"
  60. #include "nm-setting-ovs-interface.h"
  61. #include "nm-setting-ovs-patch.h"
  62. #include "nm-setting-ovs-port.h"
  63. #include "nm-setting-ppp.h"
  64. #include "nm-setting-pppoe.h"
  65. #include "nm-setting-serial.h"
  66. #include "nm-setting-sriov.h"
  67. #include "nm-setting-tc-config.h"
  68. #include "nm-setting-team-port.h"
  69. #include "nm-setting-team.h"
  70. #include "nm-setting-tun.h"
  71. #include "nm-setting-vlan.h"
  72. #include "nm-setting-vpn.h"
  73. #include "nm-setting-vxlan.h"
  74. #include "nm-setting-wimax.h"
  75. #include "nm-setting-wired.h"
  76. #include "nm-setting-wireless-security.h"
  77. #include "nm-setting-wireless.h"
  78. #include "nm-setting-wpan.h"
  79. #include "nm-setting.h"
  80. #include "nm-simple-connection.h"
  81. #include "nm-utils.h"
  82. #include "nm-vpn-dbus-interface.h"
  83. #include "nm-core-types-internal.h"
  84. #include "nm-vpn-editor-plugin.h"
  85. #include "nm-meta-setting.h"
  86. /* IEEE 802.1D-1998 timer values */
  87. #define NM_BR_MIN_HELLO_TIME 1
  88. #define NM_BR_MAX_HELLO_TIME 10
  89. #define NM_BR_MIN_FORWARD_DELAY 2
  90. #define NM_BR_MAX_FORWARD_DELAY 30
  91. #define NM_BR_MIN_MAX_AGE 6
  92. #define NM_BR_MAX_MAX_AGE 40
  93. /* IEEE 802.1D-1998 Table 7.4 */
  94. #define NM_BR_MIN_AGEING_TIME 0
  95. #define NM_BR_MAX_AGEING_TIME 1000000
  96. /* NM_SETTING_COMPARE_FLAG_INFERRABLE: check whether a device-generated
  97. * connection can be replaced by a already-defined connection. This flag only
  98. * takes into account properties marked with the %NM_SETTING_PARAM_INFERRABLE
  99. * flag.
  100. */
  101. #define NM_SETTING_COMPARE_FLAG_INFERRABLE ((NMSettingCompareFlags) 0x80000000)
  102. /* NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY: this flag is used for properties
  103. * that automatically get re-applied on an active connection when the settings
  104. * connection is modified. For most properties, the applied-connection is distinct
  105. * from the setting-connection and changes don't propagate. Exceptions are the
  106. * firewall-zone and the metered property.
  107. */
  108. #define NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY ((NMSettingCompareFlags) 0x40000000)
  109. /* NM_SETTING_COMPARE_FLAG_NONE: for convenience, define a special flag NONE -- which
  110. * equals to numeric zero (NM_SETTING_COMPARE_FLAG_EXACT).
  111. */
  112. #define NM_SETTING_COMPARE_FLAG_NONE ((NMSettingCompareFlags) 0)
  113. #define NM_SETTING_SECRET_FLAGS_ALL \
  114. (NM_SETTING_SECRET_FLAG_NONE | \
  115. NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
  116. NM_SETTING_SECRET_FLAG_NOT_SAVED | \
  117. NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
  118. typedef enum { /*< skip >*/
  119. NM_SETTING_PARSE_FLAGS_NONE = 0,
  120. NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
  121. NM_SETTING_PARSE_FLAGS_BEST_EFFORT = 1LL << 1,
  122. NM_SETTING_PARSE_FLAGS_NORMALIZE = 1LL << 2,
  123. _NM_SETTING_PARSE_FLAGS_LAST,
  124. NM_SETTING_PARSE_FLAGS_ALL = ((_NM_SETTING_PARSE_FLAGS_LAST - 1) << 1) - 1,
  125. } NMSettingParseFlags;
  126. gboolean _nm_connection_replace_settings (NMConnection *connection,
  127. GVariant *new_settings,
  128. NMSettingParseFlags parse_flags,
  129. GError **error);
  130. gpointer _nm_connection_check_main_setting (NMConnection *connection,
  131. const char *setting_name,
  132. GError **error);
  133. /**
  134. * NMSettingVerifyResult:
  135. * @NM_SETTING_VERIFY_SUCCESS: the setting verifies successfully
  136. * @NM_SETTING_VERIFY_ERROR: the setting has a serious misconfiguration
  137. * @NM_SETTING_VERIFY_NORMALIZABLE: the setting is valid but has properties
  138. * that should be normalized
  139. * @NM_SETTING_VERIFY_NORMALIZABLE_ERROR: the setting is invalid but the
  140. * errors can be fixed by nm_connection_normalize().
  141. */
  142. typedef enum {
  143. NM_SETTING_VERIFY_SUCCESS = TRUE,
  144. NM_SETTING_VERIFY_ERROR = FALSE,
  145. NM_SETTING_VERIFY_NORMALIZABLE = 2,
  146. NM_SETTING_VERIFY_NORMALIZABLE_ERROR = 3,
  147. } NMSettingVerifyResult;
  148. NMSettingVerifyResult _nm_connection_verify (NMConnection *connection, GError **error);
  149. gboolean _nm_connection_remove_setting (NMConnection *connection, GType setting_type);
  150. NMConnection *_nm_simple_connection_new_from_dbus (GVariant *dict,
  151. NMSettingParseFlags parse_flags,
  152. GError **error);
  153. NMSettingPriority _nm_setting_get_setting_priority (NMSetting *setting);
  154. gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
  155. /*****************************************************************************/
  156. GHashTable *_nm_setting_gendata_hash (NMSetting *setting,
  157. gboolean create_if_necessary);
  158. void _nm_setting_gendata_notify (NMSetting *setting,
  159. gboolean keys_changed);
  160. guint _nm_setting_gendata_get_all (NMSetting *setting,
  161. const char *const**out_names,
  162. GVariant *const**out_values);
  163. gboolean _nm_setting_gendata_reset_from_hash (NMSetting *setting,
  164. GHashTable *new);
  165. void _nm_setting_gendata_to_gvalue (NMSetting *setting,
  166. GValue *value);
  167. GVariant *nm_setting_gendata_get (NMSetting *setting,
  168. const char *name);
  169. const char *const*nm_setting_gendata_get_all_names (NMSetting *setting,
  170. guint *out_len);
  171. GVariant *const*nm_setting_gendata_get_all_values (NMSetting *setting);
  172. /*****************************************************************************/
  173. guint nm_setting_ethtool_init_features (NMSettingEthtool *setting,
  174. NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */);
  175. /*****************************************************************************/
  176. #define NM_UTILS_HWADDR_LEN_MAX_STR (NM_UTILS_HWADDR_LEN_MAX * 3)
  177. guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_length, gsize *out_length);
  178. const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len);
  179. char *_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case);
  180. void _nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
  181. guint8 *_nm_utils_str2bin_full (const char *asc,
  182. gboolean delimiter_required,
  183. const char *delimiter_candidates,
  184. guint8 *buffer,
  185. gsize buffer_length,
  186. gsize *out_len);
  187. GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
  188. GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
  189. typedef gpointer (*NMUtilsCopyFunc) (gpointer);
  190. const char **_nm_ip_address_get_attribute_names (const NMIPAddress *addr, gboolean sorted, guint *out_length);
  191. gboolean _nm_ip_route_attribute_validate_all (const NMIPRoute *route);
  192. const char **_nm_ip_route_get_attribute_names (const NMIPRoute *route, gboolean sorted, guint *out_length);
  193. GHashTable *_nm_ip_route_get_attributes_direct (NMIPRoute *route);
  194. NMSriovVF *_nm_utils_sriov_vf_from_strparts (const char *index, const char *detail, GError **error);
  195. gboolean _nm_sriov_vf_attribute_validate_all (const NMSriovVF *vf, GError **error);
  196. static inline void
  197. _nm_auto_ip_route_unref (NMIPRoute **v)
  198. {
  199. if (*v)
  200. nm_ip_route_unref (*v);
  201. }
  202. #define nm_auto_ip_route_unref nm_auto (_nm_auto_ip_route_unref)
  203. GPtrArray *_nm_utils_copy_array (const GPtrArray *array,
  204. NMUtilsCopyFunc copy_func,
  205. GDestroyNotify free_func);
  206. GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array);
  207. gssize _nm_utils_ptrarray_find_first (gconstpointer *list, gssize len, gconstpointer needle);
  208. GSList * _nm_utils_strv_to_slist (char **strv, gboolean deep_copy);
  209. char ** _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy);
  210. GPtrArray * _nm_utils_strv_to_ptrarray (char **strv);
  211. char ** _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray);
  212. gboolean _nm_utils_strv_equal (char **strv1, char **strv2);
  213. gboolean _nm_utils_check_file (const char *filename,
  214. gint64 check_owner,
  215. NMUtilsCheckFilePredicate check_file,
  216. gpointer user_data,
  217. struct stat *out_st,
  218. GError **error);
  219. gboolean _nm_utils_check_module_file (const char *name,
  220. int check_owner,
  221. NMUtilsCheckFilePredicate check_file,
  222. gpointer user_data,
  223. GError **error);
  224. #define NM_UTILS_UUID_TYPE_LEGACY 0
  225. #define NM_UTILS_UUID_TYPE_VARIANT3 1
  226. char *nm_utils_uuid_generate_from_string (const char *s, gssize slen, int uuid_type, gpointer type_args);
  227. /* arbitrarily chosen namespace UUID for _nm_utils_uuid_generate_from_strings() */
  228. #define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
  229. char *_nm_utils_uuid_generate_from_strings (const char *string1, ...) G_GNUC_NULL_TERMINATED;
  230. char *nm_utils_uuid_generate_buf_ (char *buf);
  231. #define nm_utils_uuid_generate_buf(buf) \
  232. ({ \
  233. G_STATIC_ASSERT (sizeof (buf) == G_N_ELEMENTS (buf) && sizeof (buf) >= 37); \
  234. nm_utils_uuid_generate_buf_ (buf); \
  235. })
  236. #define nm_utils_uuid_generate_a() (nm_utils_uuid_generate_buf_ (g_alloca (37)))
  237. void _nm_dbus_errors_init (void);
  238. extern gboolean _nm_utils_is_manager_process;
  239. gulong _nm_dbus_signal_connect_data (GDBusProxy *proxy,
  240. const char *signal_name,
  241. const GVariantType *signature,
  242. GCallback c_handler,
  243. gpointer data,
  244. GClosureNotify destroy_data,
  245. GConnectFlags connect_flags);
  246. #define _nm_dbus_signal_connect(proxy, name, signature, handler, data) \
  247. _nm_dbus_signal_connect_data (proxy, name, signature, handler, data, NULL, (GConnectFlags) 0)
  248. GVariant *_nm_dbus_proxy_call_finish (GDBusProxy *proxy,
  249. GAsyncResult *res,
  250. const GVariantType *reply_type,
  251. GError **error);
  252. GVariant *_nm_dbus_proxy_call_sync (GDBusProxy *proxy,
  253. const char *method_name,
  254. GVariant *parameters,
  255. const GVariantType *reply_type,
  256. GDBusCallFlags flags,
  257. int timeout_msec,
  258. GCancellable *cancellable,
  259. GError **error);
  260. gboolean _nm_dbus_error_has_name (GError *error,
  261. const char *dbus_error_name);
  262. /*****************************************************************************/
  263. char *_nm_utils_ssid_to_string_arr (const guint8 *ssid, gsize len);
  264. char *_nm_utils_ssid_to_string (GBytes *ssid);
  265. char *_nm_utils_ssid_to_utf8 (GBytes *ssid);
  266. gboolean _nm_utils_is_empty_ssid (GBytes *ssid);
  267. /*****************************************************************************/
  268. gboolean _nm_vpn_plugin_info_check_file (const char *filename,
  269. gboolean check_absolute,
  270. gboolean do_validate_filename,
  271. gint64 check_owner,
  272. NMUtilsCheckFilePredicate check_file,
  273. gpointer user_data,
  274. GError **error);
  275. const char *_nm_vpn_plugin_info_get_default_dir_etc (void);
  276. const char *_nm_vpn_plugin_info_get_default_dir_lib (void);
  277. const char *_nm_vpn_plugin_info_get_default_dir_user (void);
  278. GSList *_nm_vpn_plugin_info_list_load_dir (const char *dirname,
  279. gboolean do_validate_filename,
  280. gint64 check_owner,
  281. NMUtilsCheckFilePredicate check_file,
  282. gpointer user_data);
  283. /*****************************************************************************/
  284. typedef struct {
  285. const char *name;
  286. gboolean numeric;
  287. gboolean ipv6_only;
  288. } NMUtilsDNSOptionDesc;
  289. extern const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[];
  290. gboolean _nm_utils_dns_option_validate (const char *option, char **out_name,
  291. long *out_value, gboolean ipv6,
  292. const NMUtilsDNSOptionDesc *option_descs);
  293. gssize _nm_utils_dns_option_find_idx (GPtrArray *array, const char *option);
  294. /*****************************************************************************/
  295. typedef struct _NMUtilsStrStrDictKey NMUtilsStrStrDictKey;
  296. guint _nm_utils_strstrdictkey_hash (gconstpointer a);
  297. gboolean _nm_utils_strstrdictkey_equal (gconstpointer a, gconstpointer b);
  298. NMUtilsStrStrDictKey *_nm_utils_strstrdictkey_create (const char *v1, const char *v2);
  299. #define _nm_utils_strstrdictkey_static(v1, v2) \
  300. ( (NMUtilsStrStrDictKey *) ("\03" v1 "\0" v2 "") )
  301. /*****************************************************************************/
  302. gboolean _nm_setting_vlan_set_priorities (NMSettingVlan *setting,
  303. NMVlanPriorityMap map,
  304. const NMVlanQosMapping *qos_map,
  305. guint n_qos_map);
  306. void _nm_setting_vlan_get_priorities (NMSettingVlan *setting,
  307. NMVlanPriorityMap map,
  308. NMVlanQosMapping **out_qos_map,
  309. guint *out_n_qos_map);
  310. /*****************************************************************************/
  311. struct ether_addr;
  312. gboolean _nm_utils_generate_mac_address_mask_parse (const char *value,
  313. struct ether_addr *out_mask,
  314. struct ether_addr **out_ouis,
  315. gsize *out_ouis_len,
  316. GError **error);
  317. /*****************************************************************************/
  318. typedef enum {
  319. NM_BOND_OPTION_TYPE_INT,
  320. NM_BOND_OPTION_TYPE_STRING,
  321. NM_BOND_OPTION_TYPE_BOTH,
  322. NM_BOND_OPTION_TYPE_IP,
  323. NM_BOND_OPTION_TYPE_MAC,
  324. NM_BOND_OPTION_TYPE_IFNAME,
  325. } NMBondOptionType;
  326. NMBondOptionType
  327. _nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name);
  328. /*****************************************************************************/
  329. /* nm_connection_get_uuid() asserts against NULL, which is the right thing to
  330. * do in order to catch bugs. However, sometimes that behavior is inconvenient.
  331. * Just try or return NULL. */
  332. static inline const char *
  333. _nm_connection_get_id (NMConnection *connection)
  334. {
  335. return connection ? nm_connection_get_id (connection) : NULL;
  336. }
  337. static inline const char *
  338. _nm_connection_get_uuid (NMConnection *connection)
  339. {
  340. return connection ? nm_connection_get_uuid (connection) : NULL;
  341. }
  342. NMConnectionMultiConnect _nm_connection_get_multi_connect (NMConnection *connection);
  343. /*****************************************************************************/
  344. typedef enum {
  345. NM_BOND_MODE_UNKNOWN = 0,
  346. NM_BOND_MODE_ROUNDROBIN,
  347. NM_BOND_MODE_ACTIVEBACKUP,
  348. NM_BOND_MODE_XOR,
  349. NM_BOND_MODE_BROADCAST,
  350. NM_BOND_MODE_8023AD,
  351. NM_BOND_MODE_TLB,
  352. NM_BOND_MODE_ALB,
  353. } NMBondMode;
  354. NMBondMode _nm_setting_bond_mode_from_string (const char *str);
  355. gboolean _nm_setting_bond_option_supported (const char *option, NMBondMode mode);
  356. /*****************************************************************************/
  357. NMSettingBluetooth *_nm_connection_get_setting_bluetooth_for_nap (NMConnection *connection);
  358. /*****************************************************************************/
  359. const char *nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst);
  360. gboolean _nm_utils_inet6_is_token (const struct in6_addr *in6addr);
  361. /*****************************************************************************/
  362. gboolean _nm_utils_team_config_equal (const char *conf1, const char *conf2, gboolean port);
  363. GValue *_nm_utils_team_config_get (const char *conf,
  364. const char *key,
  365. const char *key2,
  366. const char *key3,
  367. gboolean port_config);
  368. gboolean _nm_utils_team_config_set (char **conf,
  369. const char *key,
  370. const char *key2,
  371. const char *key3,
  372. const GValue *value);
  373. /*****************************************************************************/
  374. static inline int
  375. nm_setting_ip_config_get_addr_family (NMSettingIPConfig *s_ip)
  376. {
  377. if (NM_IS_SETTING_IP4_CONFIG (s_ip))
  378. return AF_INET;
  379. if (NM_IS_SETTING_IP6_CONFIG (s_ip))
  380. return AF_INET6;
  381. g_return_val_if_reached (AF_UNSPEC);
  382. }
  383. /*****************************************************************************/
  384. guint32 _nm_utils_parse_tc_handle (const char *str,
  385. GError **error);
  386. void _nm_utils_string_append_tc_parent (GString *string,
  387. const char *prefix,
  388. guint32 parent);
  389. void _nm_utils_string_append_tc_qdisc_rest (GString *string,
  390. NMTCQdisc *qdisc);
  391. gboolean _nm_utils_string_append_tc_tfilter_rest (GString *string,
  392. NMTCTfilter *tfilter,
  393. GError **error);
  394. /*****************************************************************************/
  395. static inline gboolean
  396. _nm_connection_type_is_master (const char *type)
  397. {
  398. return (NM_IN_STRSET (type,
  399. NM_SETTING_BOND_SETTING_NAME,
  400. NM_SETTING_BRIDGE_SETTING_NAME,
  401. NM_SETTING_TEAM_SETTING_NAME,
  402. NM_SETTING_OVS_BRIDGE_SETTING_NAME,
  403. NM_SETTING_OVS_PORT_SETTING_NAME));
  404. }
  405. /*****************************************************************************/
  406. gboolean _nm_utils_dhcp_duid_valid (const char *duid, GBytes **out_duid_bin);
  407. /*****************************************************************************/
  408. gboolean _nm_setting_sriov_sort_vfs (NMSettingSriov *setting);
  409. /*****************************************************************************/
  410. typedef struct _NMSettInfoSetting NMSettInfoSetting;
  411. typedef GVariant *(*NMSettingPropertyGetFunc) (NMSetting *setting,
  412. const char *property);
  413. typedef GVariant *(*NMSettingPropertySynthFunc) (NMSetting *setting,
  414. NMConnection *connection,
  415. const char *property);
  416. typedef gboolean (*NMSettingPropertySetFunc) (NMSetting *setting,
  417. GVariant *connection_dict,
  418. const char *property,
  419. GVariant *value,
  420. NMSettingParseFlags parse_flags,
  421. GError **error);
  422. typedef gboolean (*NMSettingPropertyNotSetFunc) (NMSetting *setting,
  423. GVariant *connection_dict,
  424. const char *property,
  425. NMSettingParseFlags parse_flags,
  426. GError **error);
  427. typedef GVariant *(*NMSettingPropertyTransformToFunc) (const GValue *from);
  428. typedef void (*NMSettingPropertyTransformFromFunc) (GVariant *from,
  429. GValue *to);
  430. typedef struct {
  431. const char *name;
  432. GParamSpec *param_spec;
  433. const GVariantType *dbus_type;
  434. NMSettingPropertyGetFunc get_func;
  435. NMSettingPropertySynthFunc synth_func;
  436. NMSettingPropertySetFunc set_func;
  437. NMSettingPropertyNotSetFunc not_set_func;
  438. NMSettingPropertyTransformToFunc to_dbus;
  439. NMSettingPropertyTransformFromFunc from_dbus;
  440. } NMSettInfoProperty;
  441. typedef struct {
  442. const GVariantType *(*get_variant_type) (const struct _NMSettInfoSetting *sett_info,
  443. const char *name,
  444. GError **error);
  445. } NMSettInfoSettGendata;
  446. typedef struct {
  447. /* if set, then this setting class has no own fields. Instead, its
  448. * data is entirely based on gendata. Meaning: it tracks all data
  449. * as native GVariants.
  450. * It might have some GObject properties, but these are merely accessors
  451. * to the underlying gendata.
  452. *
  453. * Note, that at the moment there are few hooks, to customize the behavior
  454. * of the setting further. They are currently unneeded. This is desired,
  455. * but could be added when there is a good reason.
  456. *
  457. * However, a few hooks there are... see NMSettInfoSettGendata. */
  458. const NMSettInfoSettGendata *gendata_info;
  459. } NMSettInfoSettDetail;
  460. struct _NMSettInfoSetting {
  461. NMSettingClass *setting_class;
  462. const NMSettInfoProperty *property_infos;
  463. guint property_infos_len;
  464. NMSettInfoSettDetail detail;
  465. };
  466. const NMSettInfoSetting *_nm_sett_info_setting_get (NMSettingClass *setting_class);
  467. const NMSettInfoProperty *_nm_sett_info_property_get (NMSettingClass *setting_class,
  468. const char *property_name);
  469. /*****************************************************************************/
  470. NMSetting8021xCKScheme _nm_setting_802_1x_cert_get_scheme (GBytes *bytes, GError **error);
  471. GBytes *_nm_setting_802_1x_cert_value_to_bytes (NMSetting8021xCKScheme scheme,
  472. const guint8 *val_bin,
  473. gssize val_len,
  474. GError **error);
  475. /*****************************************************************************/
  476. #endif