2014-07-24 12:53:33 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Copyright 2007 - 2013 Red Hat, Inc.
|
|
|
|
* Copyright 2007 - 2008 Novell, Inc.
|
|
|
|
*/
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 18:10:11 +00:00
|
|
|
#ifndef __NM_CONNECTION_H__
|
|
|
|
#define __NM_CONNECTION_H__
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-07-06 20:53:02 +00:00
|
|
|
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
|
|
|
#error "Only <NetworkManager.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2014-10-22 02:09:52 +00:00
|
|
|
#include <nm-core-types.h>
|
2014-07-24 12:53:33 +00:00
|
|
|
#include <nm-setting.h>
|
2014-10-15 17:20:03 +00:00
|
|
|
#include <nm-errors.h>
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2014-08-13 18:34:29 +00:00
|
|
|
#define NM_TYPE_CONNECTION (nm_connection_get_type ())
|
|
|
|
#define NM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION, NMConnection))
|
|
|
|
#define NM_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION))
|
|
|
|
#define NM_CONNECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
/* Signals */
|
|
|
|
#define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
|
|
|
|
#define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
|
|
|
|
#define NM_CONNECTION_CHANGED "changed"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
|
|
|
|
* when normalizing ip6 configuration. If omited, this defaults to
|
|
|
|
* @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
|
|
|
|
*/
|
|
|
|
#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NMConnection:
|
|
|
|
*
|
2014-08-13 18:34:29 +00:00
|
|
|
* NMConnection is the interface implemented by #NMRemoteConnection on the
|
|
|
|
* client side, and #NMSettingsConnection on the daemon side.
|
2014-07-24 12:53:33 +00:00
|
|
|
*/
|
|
|
|
|
2014-11-07 17:38:17 +00:00
|
|
|
/**
|
|
|
|
* NMConnectionInterface:
|
|
|
|
* @parent: the parent interace struct
|
|
|
|
* @secrets_updated: emitted when the connection's secrets are updated
|
|
|
|
* @secrets_cleared: emitted when the connection's secrets are cleared
|
|
|
|
* @changed: emitted when any change to the connection's settings occurs
|
|
|
|
*/
|
2014-07-24 12:53:33 +00:00
|
|
|
typedef struct {
|
2014-08-13 18:34:29 +00:00
|
|
|
GTypeInterface parent;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
/* Signals */
|
2014-08-13 13:07:38 +00:00
|
|
|
void (*secrets_updated) (NMConnection *connection,
|
|
|
|
const char *setting);
|
|
|
|
void (*secrets_cleared) (NMConnection *connection);
|
|
|
|
void (*changed) (NMConnection *connection);
|
2014-05-15 13:55:18 +00:00
|
|
|
|
2014-08-13 18:34:29 +00:00
|
|
|
} NMConnectionInterface;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
GType nm_connection_get_type (void);
|
|
|
|
|
|
|
|
void nm_connection_add_setting (NMConnection *connection,
|
|
|
|
NMSetting *setting);
|
|
|
|
|
|
|
|
void nm_connection_remove_setting (NMConnection *connection,
|
|
|
|
GType setting_type);
|
|
|
|
|
|
|
|
NMSetting *nm_connection_get_setting (NMConnection *connection,
|
|
|
|
GType setting_type);
|
|
|
|
|
|
|
|
NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
|
|
|
|
const char *name);
|
|
|
|
|
2014-08-16 14:09:48 +00:00
|
|
|
/**
|
|
|
|
* NM_VARIANT_TYPE_CONNECTION:
|
|
|
|
*
|
|
|
|
* #GVariantType for a dictionary mapping from setting names to
|
|
|
|
* %NM_VARIANT_TYPE_SETTING variants. This is used to represent an
|
|
|
|
* #NMConnection, and is the type taken by nm_simple_connection_new_from_dbus()
|
|
|
|
* and returned from nm_connection_to_dbus().
|
|
|
|
*/
|
|
|
|
#define NM_VARIANT_TYPE_CONNECTION (G_VARIANT_TYPE ("a{sa{sv}}"))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NM_VARIANT_TYPE_SETTING:
|
|
|
|
*
|
|
|
|
* #GVariantType for a dictionary mapping from property names to values. This is
|
|
|
|
* an alias for %G_VARIANT_TYPE_VARDICT, and is the type of each element of
|
|
|
|
* an %NM_VARIANT_TYPE_CONNECTION dictionary.
|
|
|
|
*/
|
|
|
|
#define NM_VARIANT_TYPE_SETTING G_VARIANT_TYPE_VARDICT
|
|
|
|
|
2014-08-06 23:35:31 +00:00
|
|
|
/**
|
|
|
|
* NMConnectionSerializationFlags:
|
|
|
|
* @NM_CONNECTION_SERIALIZE_ALL: serialize all properties (including secrets)
|
|
|
|
* @NM_CONNECTION_SERIALIZE_NO_SECRETS: do not include secrets
|
|
|
|
* @NM_CONNECTION_SERIALIZE_ONLY_SECRETS: only serialize secrets
|
|
|
|
*
|
|
|
|
* These flags determine which properties are serialized when calling when
|
|
|
|
* calling nm_connection_to_dbus().
|
|
|
|
**/
|
|
|
|
typedef enum { /*< flags >*/
|
|
|
|
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
|
|
|
|
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
|
|
|
|
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
|
|
|
|
} NMConnectionSerializationFlags;
|
|
|
|
|
2014-08-16 14:09:48 +00:00
|
|
|
GVariant *nm_connection_to_dbus (NMConnection *connection,
|
2014-08-06 23:35:31 +00:00
|
|
|
NMConnectionSerializationFlags flags);
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
gboolean nm_connection_replace_settings (NMConnection *connection,
|
2014-08-16 14:09:48 +00:00
|
|
|
GVariant *new_settings,
|
2014-07-24 12:53:33 +00:00
|
|
|
GError **error);
|
|
|
|
|
libnm-core: fix up connection deserialize/copy/replace semantics
libnm-util's connection deserializing/copying/replacing functions have
odd semantics where sometimes they both modify a connection AND return
an error. libnm-core tried to improve things by guaranteeing that the
connection would not be modified if the new settings were invalid, but
this ended up breaking a bunch of places that needed to be able to
work with invalid connections. So re-fix the functions by reverting
back to the old semantics, but having return values that clearly
distinguish whether the connection was modified or not.
For comparison:
- nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():
- libnm-util: returns a valid connection or NULL.
- OLD libnm-core: returned a valid connection or NULL.
- NEW libnm-core: returns a valid connection or NULL.
- nm_connection_duplicate() / nm_simple_connection_new_clone():
- libnm-util: always succeeds, whether or not the connection is
valid.
- OLD libnm-core: returned a valid connection or NULL
- NEW libnm-core: always succeeds, whether or not the connection
is valid.
- nm_connection_replace_settings_from_connection():
- libnm-util: always replaces the settings, but returns FALSE if
the connection is now invalid.
- OLD libnm-core: either replaced the settings and returned TRUE
(if the settings were valid), or else left the connection
unchanged and returned FALSE (if not).
- NEW libnm-core: always replaces the settings, and has no
return value. (The modified connection is valid if and only if
the replaced-from connection was valid; just like with the
libnm-util version.)
- nm_connection_replace_settings():
- libnm-util: returns TRUE if the new settings are valid, or
FALSE if either (a) the new settings could not be deserialized
and the connection is unchanged, or (b) the new settings were
deserialized, and the connection was updated, but is now not
valid.
- OLD libnm-core: either replaced the settings and returned TRUE
(if the settings were valid), or else left the connection
unchanged and returned FALSE (if not).
- NEW libnm-core: returns TRUE if the connection was updated
(whether or not it is valid), or FALSE if the new settings
could not be deserialized and the connection is unchanged.
2014-09-15 18:05:52 +00:00
|
|
|
void nm_connection_replace_settings_from_connection (NMConnection *connection,
|
|
|
|
NMConnection *new_connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
2014-08-22 14:14:38 +00:00
|
|
|
void nm_connection_clear_settings (NMConnection *connection);
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
gboolean nm_connection_compare (NMConnection *a,
|
|
|
|
NMConnection *b,
|
|
|
|
NMSettingCompareFlags flags);
|
|
|
|
|
|
|
|
gboolean nm_connection_diff (NMConnection *a,
|
|
|
|
NMConnection *b,
|
|
|
|
NMSettingCompareFlags flags,
|
|
|
|
GHashTable **out_settings);
|
|
|
|
|
|
|
|
gboolean nm_connection_verify (NMConnection *connection, GError **error);
|
2015-11-10 13:36:20 +00:00
|
|
|
NM_AVAILABLE_IN_1_2
|
|
|
|
gboolean nm_connection_verify_secrets (NMConnection *connection, GError **error);
|
2014-07-24 12:53:33 +00:00
|
|
|
gboolean nm_connection_normalize (NMConnection *connection,
|
|
|
|
GHashTable *parameters,
|
|
|
|
gboolean *modified,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
const char * nm_connection_need_secrets (NMConnection *connection,
|
|
|
|
GPtrArray **hints);
|
|
|
|
|
|
|
|
void nm_connection_clear_secrets (NMConnection *connection);
|
|
|
|
|
|
|
|
void nm_connection_clear_secrets_with_flags (NMConnection *connection,
|
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
gboolean nm_connection_update_secrets (NMConnection *connection,
|
|
|
|
const char *setting_name,
|
2014-08-16 14:09:48 +00:00
|
|
|
GVariant *secrets,
|
2014-07-24 12:53:33 +00:00
|
|
|
GError **error);
|
|
|
|
|
|
|
|
void nm_connection_set_path (NMConnection *connection,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
const char * nm_connection_get_path (NMConnection *connection);
|
|
|
|
|
|
|
|
const char * nm_connection_get_interface_name (NMConnection *connection);
|
|
|
|
|
|
|
|
gboolean nm_connection_is_type (NMConnection *connection, const char *type);
|
|
|
|
|
|
|
|
void nm_connection_for_each_setting_value (NMConnection *connection,
|
|
|
|
NMSettingValueIterFn func,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
void nm_connection_dump (NMConnection *connection);
|
|
|
|
|
|
|
|
/* Helpers */
|
|
|
|
const char * nm_connection_get_uuid (NMConnection *connection);
|
|
|
|
const char * nm_connection_get_id (NMConnection *connection);
|
|
|
|
const char * nm_connection_get_connection_type (NMConnection *connection);
|
|
|
|
|
2014-08-04 20:27:43 +00:00
|
|
|
gboolean nm_connection_is_virtual (NMConnection *connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
char * nm_connection_get_virtual_device_description (NMConnection *connection);
|
|
|
|
|
|
|
|
NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection);
|
|
|
|
NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection);
|
|
|
|
NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection);
|
|
|
|
NMSettingTeam * nm_connection_get_setting_team (NMConnection *connection);
|
|
|
|
NMSettingTeamPort * nm_connection_get_setting_team_port (NMConnection *connection);
|
|
|
|
NMSettingBridge * nm_connection_get_setting_bridge (NMConnection *connection);
|
|
|
|
NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnection *connection);
|
|
|
|
NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection);
|
|
|
|
NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection);
|
|
|
|
NMSettingDcb * nm_connection_get_setting_dcb (NMConnection *connection);
|
|
|
|
NMSettingGeneric * nm_connection_get_setting_generic (NMConnection *connection);
|
|
|
|
NMSettingGsm * nm_connection_get_setting_gsm (NMConnection *connection);
|
|
|
|
NMSettingInfiniband * nm_connection_get_setting_infiniband (NMConnection *connection);
|
2015-09-01 12:06:00 +00:00
|
|
|
NM_AVAILABLE_IN_1_2
|
|
|
|
NMSettingIPTunnel * nm_connection_get_setting_ip_tunnel (NMConnection *connection);
|
2014-10-19 21:30:10 +00:00
|
|
|
NMSettingIPConfig * nm_connection_get_setting_ip4_config (NMConnection *connection);
|
|
|
|
NMSettingIPConfig * nm_connection_get_setting_ip6_config (NMConnection *connection);
|
2015-09-17 16:13:49 +00:00
|
|
|
NM_AVAILABLE_IN_1_2
|
|
|
|
NMSettingMacvlan * nm_connection_get_setting_macvlan (NMConnection *connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
NMSettingOlpcMesh * nm_connection_get_setting_olpc_mesh (NMConnection *connection);
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingPpp * nm_connection_get_setting_ppp (NMConnection *connection);
|
|
|
|
NMSettingPppoe * nm_connection_get_setting_pppoe (NMConnection *connection);
|
2016-08-16 00:25:55 +00:00
|
|
|
NM_AVAILABLE_IN_1_6
|
|
|
|
NMSettingProxy * nm_connection_get_setting_proxy (NMConnection *connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
NMSettingSerial * nm_connection_get_setting_serial (NMConnection *connection);
|
2015-09-14 20:56:51 +00:00
|
|
|
NMSettingTun * nm_connection_get_setting_tun (NMConnection *connection);
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpn * nm_connection_get_setting_vpn (NMConnection *connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
NMSettingWimax * nm_connection_get_setting_wimax (NMConnection *connection);
|
|
|
|
NMSettingAdsl * nm_connection_get_setting_adsl (NMConnection *connection);
|
|
|
|
NMSettingWired * nm_connection_get_setting_wired (NMConnection *connection);
|
|
|
|
NMSettingWireless * nm_connection_get_setting_wireless (NMConnection *connection);
|
|
|
|
NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnection *connection);
|
|
|
|
NMSettingVlan * nm_connection_get_setting_vlan (NMConnection *connection);
|
2015-10-13 07:09:54 +00:00
|
|
|
NM_AVAILABLE_IN_1_2
|
|
|
|
NMSettingVxlan * nm_connection_get_setting_vxlan (NMConnection *connection);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 18:10:11 +00:00
|
|
|
#endif /* __NM_CONNECTION_H__ */
|