Top | ![]() |
![]() |
![]() |
![]() |
#define | NM_CONNECTION_SECRETS_UPDATED |
#define | NM_CONNECTION_SECRETS_CLEARED |
#define | NM_CONNECTION_CHANGED |
#define | NM_CONNECTION_PATH |
enum | NMConnectionError |
#define | NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD |
#define | NM_CONNECTION_ERROR |
NMConnection |
An NMConnection describes all the settings and configuration values that are necessary to configure network devices for operation on a specific network. Connections are the fundamental operating object for NetworkManager; no device is connected without a NMConnection, or disconnected without having been connected with a NMConnection.
Each NMConnection contains a list of NMSetting objects usually referenced
by name (using nm_connection_get_setting_by_name()
) or by type (with
nm_connection_get_setting()
). The settings describe the actual parameters
with which the network devices are configured, including device-specific
parameters (MTU, SSID, APN, channel, rate, etc) and IP-level parameters
(addresses, routes, addressing methods, etc).
GQuark
nm_connection_error_quark (void
);
Registers an error quark for NMConnection if necessary.
NMConnection *
nm_connection_new (void
);
Creates a new NMConnection object with no NMSetting objects.
NMConnection * nm_connection_new_from_hash (GHashTable *hash
,GError **error
);
Creates a new NMConnection from a hash table describing the connection. See
nm_connection_to_hash()
for a description of the expected hash table.
hash |
the GHashTable describing the connection. |
[element-type utf8 GLib.HashTable] |
error |
on unsuccessful return, an error |
the new NMConnection object, populated with settings created
from the values in the hash table, or NULL
if the connection failed to
validate
NMConnection *
nm_connection_duplicate (NMConnection *connection
);
Duplicates a NMConnection.
a new NMConnection containing the same settings and properties as the source NMConnection.
[transfer full]
NMSetting *
nm_connection_create_setting (const char *name
);
Create a new NMSetting object of the desired type, given a setting name.
void nm_connection_add_setting (NMConnection *connection
,NMSetting *setting
);
Adds a NMSetting to the connection, replacing any previous NMSetting of the same name which has previously been added to the NMConnection. The connection takes ownership of the NMSetting object and does not increase the setting object's reference count.
void nm_connection_remove_setting (NMConnection *connection
,GType setting_type
);
Removes the NMSetting with the given GType from the NMConnection. This operation dereferences the NMSetting object.
NMSetting * nm_connection_get_setting (NMConnection *connection
,GType setting_type
);
Gets the NMSetting with the given GType, if one has been previously added to the NMConnection.
the NMSetting, or NULL
if no setting of that type was previously
added to the NMConnection.
[transfer none]
NMSetting * nm_connection_get_setting_by_name (NMConnection *connection
,const char *name
);
Gets the NMSetting with the given name, if one has been previously added the NMConnection.
the NMSetting, or NULL
if no setting with that name was previously
added to the NMConnection.
[transfer none]
gboolean nm_connection_replace_settings (NMConnection *connection
,GHashTable *new_settings
,GError **error
);
connection |
||
new_settings |
a GHashTable of settings. |
[element-type utf8 GLib.HashTable] |
error |
location to store error, or |
gboolean nm_connection_replace_settings_from_connection (NMConnection *connection
,NMConnection *new_connection
,GError **error
);
Deep-copies the settings of new_conenction
and replaces the settings of connection
with the copied settings.
connection |
||
new_connection |
a NMConnection to replace the settings of |
|
error |
location to store error, or |
TRUE
if the settings were valid after replacing the connection, FALSE
if they were not. Regardless of whether TRUE
or FALSE
is returned, the connection
is successfully replaced. FALSE
only means, that the connection does not verify
at the end of the operation.
Since: 0.9.10
gboolean nm_connection_compare (NMConnection *a
,NMConnection *b
,NMSettingCompareFlags flags
);
Compares two NMConnection objects for similarity, with comparison behavior
modified by a set of flags. See nm_setting_compare()
for a description of
each flag's behavior.
a |
||
b |
a second NMConnection to compare with the first |
|
flags |
compare flags, e.g. |
gboolean nm_connection_diff (NMConnection *a
,NMConnection *b
,NMSettingCompareFlags flags
,GHashTable **out_settings
);
Compares two NMConnection objects for similarity, with comparison behavior
modified by a set of flags. See nm_setting_compare()
for a description of
each flag's behavior. If the connections differ, settings and keys within
each setting that differ are added to the returned out_settings
hash table.
No values are returned, only key names.
a |
||
b |
a second NMConnection to compare with the first |
|
flags |
compare flags, e.g. |
|
out_settings |
if the
connections differ, on return a hash table mapping setting names to
second-level GHashTable (utf8 to guint32), which contains the key names that
differ mapped to one or more of |
[element-type utf8 GLib.HashTable] |
gboolean nm_connection_verify (NMConnection *connection
,GError **error
);
Validates the connection and all its settings. Each setting's properties have allowed values, and some values are dependent on other values. For example, if a Wi-Fi connection is security enabled, the NMSettingWireless setting object's 'security' property must contain the setting name of the NMSettingWirelessSecurity object, which must also be present in the connection for the connection to be valid. As another example, the NMSettingWired object's 'mac-address' property must be a validly formatted MAC address. The returned GError contains information about which setting and which property failed validation, and how it failed validation.
gboolean nm_connection_normalize (NMConnection *connection
,GHashTable *parameters
,gboolean *modified
,GError **error
);
Does some basic normalization and fixup of well known inconsistencies
and deprecated fields. If the connection was modified in any way,
the output parameter modified
is set TRUE
.
Finally the connection will be verified and TRUE
returns if the connection
is valid. As this function only performs some specific normalization steps
it cannot repair all connections. If the connection has errors that
cannot be normalized, the connection will not be modified.
connection |
the NMConnection to normalize |
|
parameters |
a GHashTable with
normalization parameters to allow customization of the normalization by providing
specific arguments. Unknown arguments will be ignored and the default will be
used. The keys must be strings, hashed by |
[allow-none][element-type utf8 gpointer] |
modified |
outputs whether any settings were modified. |
[out][allow-none] |
error |
location to store error, or |
Since: 1.0
const char * nm_connection_need_secrets (NMConnection *connection
,GPtrArray **hints
);
Returns the name of the first setting object in the connection which would need secrets to make a successful connection. The returned hints are only intended as a guide to what secrets may be required, because in some circumstances, there is no way to conclusively determine exactly which secrets are needed.
connection |
the NMConnection |
|
hints |
the address of a pointer to a GPtrArray, initialized to |
[out][element-type utf8][allow-none][transfer container] |
void
nm_connection_clear_secrets (NMConnection *connection
);
Clears and frees any secrets that may be stored in the connection, to avoid keeping secret data in memory when not needed.
void nm_connection_clear_secrets_with_flags (NMConnection *connection
,NMSettingClearSecretsWithFlagsFn func
,gpointer user_data
);
Clears and frees secrets determined by func
.
connection |
the NMConnection |
|
func |
function to be called to determine whether a specific secret should be cleared or not. |
[scope call] |
user_data |
caller-supplied data passed to |
gboolean nm_connection_update_secrets (NMConnection *connection
,const char *setting_name
,GHashTable *secrets
,GError **error
);
Update the specified setting's secrets, given a hash table of secrets
intended for that setting (deserialized from D-Bus for example). Will also
extract the given setting's secrets hash if given a hash of hashes, as would
be returned from nm_connection_to_hash()
. If setting_name
is NULL
, expects
a fully serialized NMConnection as returned by nm_connection_to_hash()
and
will update all secrets from all settings contained in secrets
.
connection |
the NMConnection |
|
setting_name |
the setting object name to which the secrets apply |
|
secrets |
a GHashTable mapping
string:GValue of setting property names and secrets of the given |
[element-type utf8 GObject.Value] |
error |
location to store error, or |
void nm_connection_set_path (NMConnection *connection
,const char *path
);
Sets the D-Bus path of the connection. This property is not serialized, and is only for the reference of the caller. Sets the “path” property.
connection |
the NMConnection |
|
path |
the D-Bus path of the connection as given by the settings service which provides the connection |
const char *
nm_connection_get_path (NMConnection *connection
);
Returns the connection's D-Bus path.
const char *
nm_connection_get_virtual_iface_name (NMConnection *connection
);
Returns the name of the virtual kernel interface which the connection
needs to use if specified in the settings. This function abstracts all
connection types which require this functionality. For all other
connection types, this function will return NULL
.
const char *
nm_connection_get_interface_name (NMConnection *connection
);
Returns the interface name as stored in NMSettingConnection:interface_name.
If the connection contains no NMSettingConnection, it will return NULL
.
For hardware devices and software devices created outside of NetworkManager, this name is used to match the device. for software devices created by NetworkManager, this is the name of the created interface.
Since: 1.0
gboolean nm_connection_is_type (NMConnection *connection
,const char *type
);
A convenience function to check if the given connection
is a particular
type (ie wired, Wi-Fi, ppp, etc). Checks the “type”
property of the connection and matches that against type
.
connection |
the NMConnection |
|
type |
a setting name to check the connection's type against (like
|
void nm_connection_for_each_setting_value (NMConnection *connection
,NMSettingValueIterFn func
,gpointer user_data
);
Iterates over the properties of each NMSetting object in the NMConnection, calling the supplied user function for each property.
connection |
the NMConnection |
|
func |
user-supplied function called for each setting's property. |
[scope call] |
user_data |
user data passed to |
GHashTable * nm_connection_to_hash (NMConnection *connection
,NMSettingHashFlags flags
);
Converts the NMConnection into a GHashTable describing the connection, suitable for marshalling over D-Bus or serializing. The hash table mapping is string:GHashTable with each element in the returned hash representing a NMSetting object. The keys are setting object names, and the values are GHashTables mapping string:GValue, each of which represents the properties of the NMSetting object.
a new
GHashTable describing the connection, its settings, and each setting's
properties. The caller owns the hash table and must unref the hash table
with g_hash_table_unref()
when it is no longer needed.
[transfer full][element-type utf8 GLib.HashTable]
void
nm_connection_dump (NMConnection *connection
);
Print the connection to stdout. For debugging purposes ONLY, should NOT be used for serialization of the connection or machine-parsed in any way. The output format is not guaranteed to be stable and may change at any time.
GType
nm_connection_lookup_setting_type (const char *name
);
Returns the GType of the setting's class for a given setting name.
GType
nm_connection_lookup_setting_type_by_quark
(GQuark error_quark
);
Returns the GType of the setting's class for a given setting error quark. Useful for figuring out which setting a returned error is for.
const char *
nm_connection_get_uuid (NMConnection *connection
);
A shortcut to return the UUID from the connection's NMSettingConnection.
const char *
nm_connection_get_id (NMConnection *connection
);
A shortcut to return the ID from the connection's NMSettingConnection.
const char *
nm_connection_get_connection_type (NMConnection *connection
);
A shortcut to return the type from the connection's NMSettingConnection.
Since: 0.9.10
char *
nm_connection_get_virtual_device_description
(NMConnection *connection
);
Returns the name that nm_device_disambiguate_names()
would
return for the virtual device that would be created for connection
.
Eg, "VLAN (eth1.1)".
the name of connection
's device,
or NULL
if connection
is not a virtual connection type.
[transfer full]
Since: 0.9.10
NMSetting8021x *
nm_connection_get_setting_802_1x (NMConnection *connection
);
A shortcut to return any NMSetting8021x the connection might contain.
NMSettingBluetooth *
nm_connection_get_setting_bluetooth (NMConnection *connection
);
A shortcut to return any NMSettingBluetooth the connection might contain.
NMSettingBond *
nm_connection_get_setting_bond (NMConnection *connection
);
A shortcut to return any NMSettingBond the connection might contain.
NMSettingTeam *
nm_connection_get_setting_team (NMConnection *connection
);
A shortcut to return any NMSettingTeam the connection might contain.
Since: 0.9.10
NMSettingTeamPort *
nm_connection_get_setting_team_port (NMConnection *connection
);
A shortcut to return any NMSettingTeamPort the connection might contain.
Since: 0.9.10
NMSettingBridge *
nm_connection_get_setting_bridge (NMConnection *connection
);
A shortcut to return any NMSettingBridge the connection might contain.
NMSettingBridgePort *
nm_connection_get_setting_bridge_port (NMConnection *connection
);
A shortcut to return any NMSettingBridgePort the connection might contain.
NMSettingCdma *
nm_connection_get_setting_cdma (NMConnection *connection
);
A shortcut to return any NMSettingCdma the connection might contain.
NMSettingConnection *
nm_connection_get_setting_connection (NMConnection *connection
);
A shortcut to return any NMSettingConnection the connection might contain.
NMSettingDcb *
nm_connection_get_setting_dcb (NMConnection *connection
);
A shortcut to return any NMSettingDcb the connection might contain.
Since: 0.9.10
NMSettingGeneric *
nm_connection_get_setting_generic (NMConnection *connection
);
A shortcut to return any NMSettingGeneric the connection might contain.
Since: 0.9.10
NMSettingGsm *
nm_connection_get_setting_gsm (NMConnection *connection
);
A shortcut to return any NMSettingGsm the connection might contain.
NMSettingInfiniband *
nm_connection_get_setting_infiniband (NMConnection *connection
);
A shortcut to return any NMSettingInfiniband the connection might contain.
NMSettingIP4Config *
nm_connection_get_setting_ip4_config (NMConnection *connection
);
A shortcut to return any NMSettingIP4Config the connection might contain.
NMSettingIP6Config *
nm_connection_get_setting_ip6_config (NMConnection *connection
);
A shortcut to return any NMSettingIP6Config the connection might contain.
NMSettingOlpcMesh *
nm_connection_get_setting_olpc_mesh (NMConnection *connection
);
A shortcut to return any NMSettingOlpcMesh the connection might contain.
NMSettingPPP *
nm_connection_get_setting_ppp (NMConnection *connection
);
A shortcut to return any NMSettingPPP the connection might contain.
NMSettingPPPOE *
nm_connection_get_setting_pppoe (NMConnection *connection
);
A shortcut to return any NMSettingPPPOE the connection might contain.
NMSettingSerial *
nm_connection_get_setting_serial (NMConnection *connection
);
A shortcut to return any NMSettingSerial the connection might contain.
NMSettingVPN *
nm_connection_get_setting_vpn (NMConnection *connection
);
A shortcut to return any NMSettingVPN the connection might contain.
NMSettingWimax *
nm_connection_get_setting_wimax (NMConnection *connection
);
A shortcut to return any NMSettingWimax the connection might contain.
NMSettingAdsl *
nm_connection_get_setting_adsl (NMConnection *connection
);
A shortcut to return any NMSettingAdsl the connection might contain.
NMSettingWired *
nm_connection_get_setting_wired (NMConnection *connection
);
A shortcut to return any NMSettingWired the connection might contain.
NMSettingWireless *
nm_connection_get_setting_wireless (NMConnection *connection
);
A shortcut to return any NMSettingWireless the connection might contain.
NMSettingWirelessSecurity *
nm_connection_get_setting_wireless_security
(NMConnection *connection
);
A shortcut to return any NMSettingWirelessSecurity the connection might contain.
an NMSettingWirelessSecurity if the connection contains one, otherwise NULL
.
[transfer none]
NMSettingVlan *
nm_connection_get_setting_vlan (NMConnection *connection
);
A shortcut to return any NMSettingVlan the connection might contain.
Describes errors that may result from operations involving a NMConnection.
unknown or unclassified error |
||
the NMConnection object did not contain the required NMSettingConnection object, which must be present for all connections |
||
the 'type' property of the 'connection' setting did not point to a valid connection base type; ie it was not a hardware-related setting like NMSettingWired or NMSettingWireless. |
||
the NMConnection object did not contain the specified NMSetting object |
||
the NMConnection object contains a conflicting setting object |
#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
“path”
property“path” gchar *
The connection's D-Bus path, used only by the calling process as a record of the D-Bus path of the connection as provided by a settings service.
Flags: Read / Write / Construct
Default value: NULL
“changed”
signalvoid user_function (NMConnection *connection, gpointer user_data)
The ::changed signal is emitted when any property of any property (including secrets) of any setting of the connection is modified, or when settings are added or removed.
connection |
the object on which the signal is emitted |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
Since: 0.9.10
“secrets-cleared”
signalvoid user_function (NMConnection *connection, gpointer user_data)
The ::secrets-cleared signal is emitted when the secrets of a connection are cleared.
connection |
the object on which the signal is emitted |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“secrets-updated”
signalvoid user_function (NMConnection *connection, gchar *setting_name, gpointer user_data)
The ::secrets-updated signal is emitted when the secrets of a setting have been changed.
connection |
the object on which the signal is emitted |
|
setting_name |
the setting name of the NMSetting for which secrets were updated |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First