summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-18 12:36:09 +0200
committerThomas Haller <thaller@redhat.com>2015-04-21 17:51:34 +0200
commitc6529a9d748ad3c8ee37431d020a7b9223992a23 (patch)
treeadd34e4c0dd7718b1d514de717777d663e2e14b6
parentccba1b1e2d1fb2a23dd9e86d8ba44f7a3287cafb (diff)
downloadNetworkManager-c6529a9d748ad3c8ee37431d020a7b9223992a23.tar.gz
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform singleton nm_platform_get(). That made sense because the NMPlatform instance was mainly to hook fake platform for testing. While the implicit argument saved some typing, I think explicit is better. Especially, because NMPlatform could become a more usable object then just a hook for testing. With this change, NMPlatform instances can be used individually, not only as a singleton instance. Before this change, the constructor of NMLinuxPlatform could not call any nm_platform_*() functions because the singleton was not yet initialized. We could only instantiate an incomplete instance, register it via nm_platform_setup(), and then complete initialization via singleton->setup(). With this change, we can create and fully initialize NMPlatform instances before/without setting them up them as singleton. Also, currently there is no clear distinction between functions that operate on the NMPlatform instance, and functions that can be used stand-alone (e.g. nm_platform_ip4_address_to_string()). The latter can not be mocked for testing. With this change, the distinction becomes obvious. That is also useful because it becomes clearer which functions make use of the platform cache and which not. Inside nm-linux-platform.c, continue the pattern that the self instance is named @platform. That makes sense because its type is NMPlatform, and not NMLinuxPlatform what we would expect from a paramter named @self. This is a major diff that causes some pain when rebasing. Try to rebase to the parent commit of this commit as a first step. Then rebase on top of this commit using merge-strategy "ours".
-rw-r--r--src/NetworkManagerUtils.c2
-rw-r--r--src/devices/adsl/nm-device-adsl.c8
-rw-r--r--src/devices/nm-device-bond.c18
-rw-r--r--src/devices/nm-device-bridge.c20
-rw-r--r--src/devices/nm-device-ethernet.c10
-rw-r--r--src/devices/nm-device-generic.c4
-rw-r--r--src/devices/nm-device-gre.c2
-rw-r--r--src/devices/nm-device-infiniband.c10
-rw-r--r--src/devices/nm-device-macvlan.c2
-rw-r--r--src/devices/nm-device-tun.c4
-rw-r--r--src/devices/nm-device-veth.c2
-rw-r--r--src/devices/nm-device-vlan.c17
-rw-r--r--src/devices/nm-device-vxlan.c2
-rw-r--r--src/devices/nm-device.c119
-rw-r--r--src/devices/team/nm-device-team.c12
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c11
-rw-r--r--src/devices/wifi/nm-device-wifi.c38
-rw-r--r--src/devices/wwan/nm-modem-broadband.c4
-rw-r--r--src/devices/wwan/nm-modem.c6
-rw-r--r--src/main.c2
-rw-r--r--src/nm-dcb.c6
-rw-r--r--src/nm-default-route-manager.c12
-rw-r--r--src/nm-iface-helper.c20
-rw-r--r--src/nm-ip4-config.c8
-rw-r--r--src/nm-ip6-config.c8
-rw-r--r--src/nm-manager.c12
-rw-r--r--src/nm-route-manager.c8
-rw-r--r--src/platform/nm-linux-platform.c50
-rw-r--r--src/platform/nm-platform.c892
-rw-r--r--src/platform/nm-platform.h246
-rw-r--r--src/platform/tests/dump.c22
-rw-r--r--src/platform/tests/platform.c90
-rw-r--r--src/platform/tests/test-address.c70
-rw-r--r--src/platform/tests/test-cleanup.c46
-rw-r--r--src/platform/tests/test-common.c14
-rw-r--r--src/platform/tests/test-common.h2
-rw-r--r--src/platform/tests/test-link.c272
-rw-r--r--src/platform/tests/test-route.c68
-rw-r--r--src/ppp-manager/nm-ppp-manager.c4
-rw-r--r--src/rdisc/nm-lndp-rdisc.c2
-rw-r--r--src/rdisc/tests/rdisc.c4
-rw-r--r--src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c2
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.c4
-rw-r--r--src/settings/plugins/ifnet/net_parser.c4
-rw-r--r--src/tests/test-route-manager.c56
-rw-r--r--src/vpn-manager/nm-vpn-connection.c8
46 files changed, 1206 insertions, 1017 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 82d695c4d6..3153edc77c 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -1302,7 +1302,7 @@ get_new_connection_ifname (const GSList *existing,
for (i = 0; i < 500; i++) {
name = g_strdup_printf ("%s%d", prefix, i);
- if (nm_platform_link_exists (name))
+ if (nm_platform_link_exists (NM_PLATFORM_GET, name))
goto next;
for (iter = existing, found = FALSE; iter; iter = g_slist_next (iter)) {
diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c
index ce265ba447..fe26adbfcf 100644
--- a/src/devices/adsl/nm-device-adsl.c
+++ b/src/devices/adsl/nm-device-adsl.c
@@ -144,7 +144,7 @@ set_nas_iface (NMDeviceAdsl *self, int idx, const char *name)
g_return_if_fail (name != NULL);
g_warn_if_fail (priv->nas_ifindex <= 0);
- priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (name);
+ priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (NM_PLATFORM_GET, name);
g_warn_if_fail (priv->nas_ifindex > 0);
g_warn_if_fail (priv->nas_ifname == NULL);
@@ -352,7 +352,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason)
_LOGD (LOGD_ADSL, "ATM setup successful");
/* otherwise we're good for stage3 */
- nm_platform_link_set_up (priv->nas_ifindex);
+ nm_platform_link_set_up (NM_PLATFORM_GET, priv->nas_ifindex);
ret = NM_ACT_STAGE_RETURN_SUCCESS;
} else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) {
@@ -492,7 +492,7 @@ carrier_update_cb (gpointer user_data)
path = g_strdup_printf ("/sys/class/atm/%s/carrier",
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self))));
- carrier = (int) nm_platform_sysctl_get_int_checked (path, 10, 0, 1, -1);
+ carrier = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, 1, -1);
g_free (path);
if (carrier != -1)
@@ -526,7 +526,7 @@ get_atm_index (const char *iface)
path = g_strdup_printf ("/sys/class/atm/%s/atmindex",
ASSERT_VALID_PATH_COMPONENT (iface));
- idx = (int) nm_platform_sysctl_get_int_checked (path, 10, 0, G_MAXINT, -1);
+ idx = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, G_MAXINT, -1);
g_free (path);
return idx;
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 52f1022aae..b41bd14eee 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -143,7 +143,7 @@ set_bond_attr (NMDevice *device, const char *attr, const char *value)
gboolean ret;
int ifindex = nm_device_get_ifindex (device);
- ret = nm_platform_master_set_option (ifindex, attr, value);
+ ret = nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, attr, value);
if (!ret)
_LOGW (LOGD_HW, "failed to set bonding attribute '%s' to '%s'", attr, value);
return ret;
@@ -177,7 +177,7 @@ update_connection (NMDevice *device, NMConnection *connection)
/* Read bond options from sysfs and update the Bond setting to match */
options = nm_setting_bond_get_valid_options (s_bond);
while (options && *options) {
- gs_free char *value = nm_platform_master_get_option (ifindex, *options);
+ gs_free char *value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, *options);
const char *defvalue = nm_setting_bond_get_option_default (s_bond, *options);
if (value && !ignore_if_zero (*options, value) && (g_strcmp0 (value, defvalue) != 0)) {
@@ -333,7 +333,7 @@ apply_bonding_config (NMDevice *device)
}
/* Clear ARP targets */
- contents = nm_platform_master_get_option (ifindex, "arp_ip_target");
+ contents = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "arp_ip_target");
set_arp_targets (device, contents, " \n", "-");
g_free (contents);
@@ -409,7 +409,8 @@ enslave_slave (NMDevice *device,
if (configure) {
nm_device_take_down (slave, TRUE);
- success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device),
+ success = nm_platform_link_enslave (NM_PLATFORM_GET,
+ nm_device_get_ip_ifindex (device),
nm_device_get_ip_ifindex (slave));
nm_device_bring_up (slave, TRUE, &no_firmware);
@@ -433,7 +434,8 @@ release_slave (NMDevice *device,
gboolean success = TRUE, no_firmware = FALSE;
if (configure) {
- success = nm_platform_link_release (nm_device_get_ip_ifindex (device),
+ success = nm_platform_link_release (NM_PLATFORM_GET,
+ nm_device_get_ip_ifindex (device),
nm_device_get_ip_ifindex (slave));
if (success) {
@@ -579,11 +581,11 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
iface = nm_connection_get_interface_name (connection);
g_return_val_if_fail (iface != NULL, NULL);
- if ( !nm_platform_bond_add (iface)
- && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
+ if ( !nm_platform_bond_add (NM_PLATFORM_GET, iface)
+ && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
nm_log_warn (LOGD_DEVICE | LOGD_BOND, "(%s): failed to create bonding master interface for '%s': %s",
iface, nm_connection_get_id (connection),
- nm_platform_get_error_msg ());
+ nm_platform_get_error_msg (NM_PLATFORM_GET));
return NULL;
}
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 48f2acfff6..0d9a76c466 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -212,9 +212,9 @@ commit_option (NMDevice *device, NMSetting *setting, const Option *option, gbool
value = g_strdup_printf ("%u", uval);
if (slave)
- nm_platform_slave_set_option (ifindex, option->sysname, value);
+ nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
else
- nm_platform_master_set_option (ifindex, option->sysname, value);
+ nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value);
}
static void
@@ -258,7 +258,7 @@ update_connection (NMDevice *device, NMConnection *connection)
}
for (option = master_options; option->name; option++) {
- gs_free char *str = nm_platform_master_get_option (ifindex, option->sysname);
+ gs_free char *str = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option->sysname);
int value;
if (str) {
@@ -297,7 +297,7 @@ master_update_slave_connection (NMDevice *device,
}
for (option = slave_options; option->name; option++) {
- gs_free char *str = nm_platform_slave_get_option (ifindex_slave, option->sysname);
+ gs_free char *str = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex_slave, option->sysname);
int value;
if (str) {
@@ -345,7 +345,7 @@ enslave_slave (NMDevice *device,
NMDeviceBridge *self = NM_DEVICE_BRIDGE (device);
if (configure) {
- if (!nm_platform_link_enslave (nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)))
+ if (!nm_platform_link_enslave (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)))
return FALSE;
commit_slave_options (slave, nm_connection_get_setting_bridge_port (connection));
@@ -371,7 +371,8 @@ release_slave (NMDevice *device,
gboolean success = TRUE;
if (configure) {
- success = nm_platform_link_release (nm_device_get_ip_ifindex (device),
+ success = nm_platform_link_release (NM_PLATFORM_GET,
+ nm_device_get_ip_ifindex (device),
nm_device_get_ip_ifindex (slave));
if (success) {
@@ -518,13 +519,14 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
mac_address_str = NULL;
}
- if ( !nm_platform_bridge_add (iface,
+ if ( !nm_platform_bridge_add (NM_PLATFORM_GET,
+ iface,
mac_address_str ? mac_address : NULL,
mac_address_str ? ETH_ALEN : 0)
- && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
+ && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
nm_log_warn (LOGD_DEVICE | LOGD_BRIDGE, "(%s): failed to create bridge master interface for '%s': %s",
iface, nm_connection_get_id (connection),
- nm_platform_get_error_msg ());
+ nm_platform_get_error_msg (NM_PLATFORM_GET));
return NULL;
}
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index f83b56d6f7..05bde3584d 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -210,7 +210,7 @@ _update_s390_subchannels (NMDeviceEthernet *self)
|| !strcmp (item, "portno")) {
char *path, *value;
path = g_strdup_printf ("%s/%s", parent_path, item);
- value = nm_platform_sysctl_get (path);
+ value = nm_platform_sysctl_get (NM_PLATFORM_GET, path);
if (value && *value)
g_hash_table_insert (priv->s390_options, g_strdup (item), g_strdup (value));
else
@@ -263,7 +263,7 @@ constructor (GType type,
if (object) {
#ifndef G_DISABLE_ASSERT
int ifindex = nm_device_get_ifindex (NM_DEVICE (object));
- NMLinkType link_type = nm_platform_link_get_type (ifindex);
+ NMLinkType link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
g_assert ( link_type == NM_LINK_TYPE_ETHERNET
|| link_type == NM_LINK_TYPE_VETH
@@ -375,7 +375,7 @@ get_generic_capabilities (NMDevice *device)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
- if (nm_platform_link_supports_carrier_detect (nm_device_get_ifindex (device)))
+ if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (device)))
return NM_DEVICE_CAP_CARRIER_DETECT;
else {
_LOGI (LOGD_HW, "driver '%s' does not support carrier detection.",
@@ -1160,7 +1160,7 @@ dcb_state (NMDevice *device, gboolean timeout)
g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG);
- carrier = nm_platform_link_is_connected (nm_device_get_ifindex (device));
+ carrier = nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device));
_LOGD (LOGD_DCB, "dcb_state() wait %d carrier %d timeout %d", priv->dcb_wait, carrier, timeout);
switch (priv->dcb_wait) {
@@ -1278,7 +1278,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB);
if (s_dcb) {
/* lldpad really really wants the carrier to be up */
- if (nm_platform_link_is_connected (nm_device_get_ifindex (device))) {
+ if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) {
if (!dcb_enable (device)) {
*reason = NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED;
return NM_ACT_STAGE_RETURN_FAILURE;
diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c
index 0704c7d313..8b328e07fe 100644
--- a/src/devices/nm-device-generic.c
+++ b/src/devices/nm-device-generic.c
@@ -48,7 +48,7 @@ enum {
static NMDeviceCapabilities
get_generic_capabilities (NMDevice *dev)
{
- if (nm_platform_link_supports_carrier_detect (nm_device_get_ifindex (dev)))
+ if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (dev)))
return NM_DEVICE_CAP_CARRIER_DETECT;
else
return NM_DEVICE_CAP_NONE;
@@ -117,7 +117,7 @@ constructed (GObject *object)
int ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self));
if (ifindex != 0)
- priv->type_description = g_strdup (nm_platform_link_get_type_name (ifindex));
+ priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex));
}
G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object);
diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c
index 9c25b398ce..6313bfd714 100644
--- a/src/devices/nm-device-gre.c
+++ b/src/devices/nm-device-gre.c
@@ -71,7 +71,7 @@ update_properties (NMDevice *device)
GObject *object = G_OBJECT (device);
NMPlatformGreProperties props;
- if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) {
+ if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
_LOGW (LOGD_HW, "could not read gre properties");
return;
}
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index cfb15c76e4..0a3b17c708 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -105,7 +105,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
}
}
- ok = nm_platform_sysctl_set (mode_path, transport_mode);
+ ok = nm_platform_sysctl_set (NM_PLATFORM_GET, mode_path, transport_mode);
g_free (mode_path);
if (!ok) {
@@ -226,7 +226,7 @@ update_connection (NMDevice *device, NMConnection *connection)
mode_path = g_strdup_printf ("/sys/class/net/%s/mode",
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (device)));
- contents = nm_platform_sysctl_get (mode_path);
+ contents = nm_platform_sysctl_get (NM_PLATFORM_GET, mode_path);
g_free (mode_path);
if (contents) {
if (strstr (contents, "datagram"))
@@ -328,11 +328,11 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
parent_ifindex = nm_device_get_ifindex (parent);
p_key = nm_setting_infiniband_get_p_key (s_infiniband);
- if ( !nm_platform_infiniband_partition_add (parent_ifindex, p_key)
- && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
+ if ( !nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key)
+ && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
nm_log_warn (LOGD_DEVICE | LOGD_INFINIBAND, "(%s): failed to add InfiniBand P_Key interface for '%s': %s",
iface, nm_connection_get_id (connection),
- nm_platform_get_error_msg ());
+ nm_platform_get_error_msg (NM_PLATFORM_GET));
return NULL;
}
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index bcd3861774..608e541db0 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.c
@@ -64,7 +64,7 @@ update_properties (NMDevice *device)
GObject *object = G_OBJECT (device);
NMPlatformMacvlanProperties props;
- if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) {
+ if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
_LOGW (LOGD_HW, "could not read macvlan properties");
return;
}
diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c
index 9a3fab5ec8..4f4ed69b25 100644
--- a/src/devices/nm-device-tun.c
+++ b/src/devices/nm-device-tun.c
@@ -65,7 +65,7 @@ reload_tun_properties (NMDeviceTun *self)
GObject *object = G_OBJECT (self);
NMPlatformTunProperties props;
- if (!nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (self)), &props)) {
+ if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &props)) {
_LOGD (LOGD_HW, "could not read tun properties");
return;
}
@@ -123,7 +123,7 @@ constructed (GObject *object)
gboolean properties_read;
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self);
- properties_read = nm_platform_tun_get_properties (nm_device_get_ifindex (NM_DEVICE (self)), &priv->props);
+ properties_read = nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &priv->props);
G_OBJECT_CLASS (nm_device_tun_parent_class)->constructed (object);
diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c
index 30994971ec..7650502c2d 100644
--- a/src/devices/nm-device-veth.c
+++ b/src/devices/nm-device-veth.c
@@ -82,7 +82,7 @@ get_peer (NMDeviceVeth *self)
if (priv->ever_had_peer)
return priv->peer;
- if (!nm_platform_veth_get_properties (nm_device_get_ifindex (device), &props)) {
+ if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
_LOGW (LOGD_HW, "could not read veth properties");
return NULL;
}
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 2f32d3165b..34fa585488 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -281,7 +281,7 @@ update_connection (NMDevice *device, NMConnection *connection)
nm_connection_add_setting (connection, (NMSetting *) s_vlan);
}
- if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) {
+ if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent_ifindex, &vlan_id)) {
_LOGW (LOGD_VLAN, "failed to get VLAN interface info while updating connection.");
return;
}
@@ -353,12 +353,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_INGRESS_MAP);
for (i = 0; i < num; i++) {
if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_INGRESS_MAP, i, &from, &to))
- nm_platform_vlan_set_ingress_map (ifindex, from, to);
+ nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, from, to);
}
num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP);
for (i = 0; i < num; i++) {
if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, i, &from, &to))
- nm_platform_vlan_set_egress_map (ifindex, from, to);
+ nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, from, to);
}
}
@@ -437,14 +437,14 @@ constructed (GObject *object)
return;
}
- itype = nm_platform_link_get_type (ifindex);
+ itype = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
if (itype != NM_LINK_TYPE_VLAN) {
_LOGE (LOGD_VLAN, "failed to get VLAN interface type.");
priv->invalid = TRUE;
return;
}
- if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) {
+ if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent_ifindex, &vlan_id)) {
_LOGW (LOGD_VLAN, "failed to get VLAN interface info.");
priv->invalid = TRUE;
return;
@@ -603,7 +603,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
return NULL;
/* Have to find the parent device */
- if (!nm_platform_vlan_get_info (plink->ifindex, &parent_ifindex, NULL)) {
+ if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, plink->ifindex, &parent_ifindex, NULL)) {
nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", plink->name);
return NULL;
}
@@ -662,11 +662,12 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
nm_setting_vlan_get_id (s_vlan));
}
- if ( !nm_platform_vlan_add (iface,
+ if ( !nm_platform_vlan_add (NM_PLATFORM_GET,
+ iface,
nm_device_get_ifindex (parent),
nm_setting_vlan_get_id (s_vlan),
nm_setting_vlan_get_flags (s_vlan))
- && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
+ && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
nm_log_warn (LOGD_DEVICE | LOGD_VLAN, "(%s) failed to add VLAN interface for '%s'",
iface, nm_connection_get_id (connection));
g_free (iface);
diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c
index ed6b8fa051..25ee804dfa 100644
--- a/src/devices/nm-device-vxlan.c
+++ b/src/devices/nm-device-vxlan.c
@@ -76,7 +76,7 @@ update_properties (NMDevice *device)
GObject *object = G_OBJECT (device);
NMPlatformVxlanProperties props;
- if (!nm_platform_vxlan_get_properties (nm_device_get_ifindex (device), &props)) {
+ if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
_LOGW (LOGD_HW, "could not read vxlan properties");
return;
}
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index b06f881d02..1de4e4730b 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -466,13 +466,13 @@ reason_to_string (NMDeviceStateReason reason)
gboolean
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
{
- return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
+ return nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
}
static guint32
nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback)
{
- return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
+ return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
}
gboolean
@@ -580,13 +580,13 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
priv->ip_iface = g_strdup (iface);
if (priv->ip_iface) {
- priv->ip_ifindex = nm_platform_link_get_ifindex (priv->ip_iface);
+ priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
if (priv->ip_ifindex > 0) {
- if (nm_platform_check_support_user_ipv6ll ())
- nm_platform_link_set_user_ipv6ll_enabled (priv->ip_ifindex, TRUE);
+ if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET))
+ nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE);
- if (!nm_platform_link_is_up (priv->ip_ifindex))
- nm_platform_link_set_up (priv->ip_ifindex);
+ if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex))
+ nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex);
} else {
/* Device IP interface must always be a kernel network interface */
_LOGW (LOGD_HW, "failed to look up interface index");
@@ -616,10 +616,10 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
ifindex = nm_device_get_ip_ifindex (self);
g_assert (ifindex);
- link_type = nm_platform_link_get_type (ifindex);
+ link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
g_return_val_if_fail (link_type > NM_LINK_TYPE_UNKNOWN, 0);
- hwaddr = nm_platform_link_get_address (ifindex, &hwaddr_len);
+ hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len);
if (!hwaddr_len)
return FALSE;
@@ -1051,7 +1051,7 @@ nm_device_finish_init (NMDevice *self)
/* Do not manage externally created software devices until they are IFF_UP */
if ( NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)
- && !nm_platform_link_is_up (priv->ifindex)
+ && !nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex)
&& priv->ifindex > 0)
nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE);
@@ -1239,7 +1239,7 @@ device_set_master (NMDevice *self, int ifindex)
} else {
_LOGW (LOGD_DEVICE, "enslaved to unknown device %d %s",
ifindex,
- nm_platform_link_get_name (ifindex));
+ nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
}
}
@@ -1295,7 +1295,7 @@ device_link_changed (NMDevice *self, NMPlatformLink *info)
nm_device_enslave_slave (priv->master, self, NULL);
}
- if (priv->rdisc && nm_platform_link_get_ipv6_token (priv->ifindex, &token_iid)) {
+ if (priv->rdisc && nm_platform_link_get_ipv6_token (NM_PLATFORM_GET, priv->ifindex, &token_iid)) {
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
if (nm_rdisc_set_iid (priv->rdisc, token_iid))
nm_rdisc_start (priv->rdisc);
@@ -1988,7 +1988,7 @@ device_has_config (NMDevice *self)
return TRUE;
/* Slaves are also configured by definition */
- if (nm_platform_link_get_master (priv->ifindex) > 0)
+ if (nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) > 0)
return TRUE;
return FALSE;
@@ -2854,9 +2854,9 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat
GArray *routes;
if (addr_family == AF_INET)
- routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
+ routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
else
- routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
+ routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
if (routes) {
guint route_metric = G_MAXUINT32, m;
@@ -3206,7 +3206,7 @@ dhcp4_start (NMDevice *self,
g_object_unref (priv->dhcp4_config);
priv->dhcp4_config = nm_dhcp4_config_new ();
- hw_addr = nm_platform_link_get_address (nm_device_get_ip_ifindex (self), &hw_addr_len);
+ hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len);
if (hw_addr_len) {
tmp = g_byte_array_sized_new (hw_addr_len);
g_byte_array_append (tmp, hw_addr, hw_addr_len);
@@ -3822,7 +3822,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_assert (s_ip6);
- hw_addr = nm_platform_link_get_address (nm_device_get_ip_ifindex (self), &hw_addr_len);
+ hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len);
if (hw_addr_len) {
tmp = g_byte_array_sized_new (hw_addr_len);
g_byte_array_append (tmp, hw_addr, hw_addr_len);
@@ -4027,7 +4027,8 @@ check_and_add_ipv6ll_addr (NMDevice *self)
lladdr.s6_addr16[0] = htons (0xfe80);
nm_utils_ipv6_addr_set_interface_identfier (&lladdr, iid);
_LOGD (LOGD_IP6, "adding IPv6LL address %s", nm_utils_inet6_ntop (&lladdr, NULL));
- if (!nm_platform_ip6_address_add (ip_ifindex,
+ if (!nm_platform_ip6_address_add (NM_PLATFORM_GET,
+ ip_ifindex,
lladdr,
in6addr_any,
64,
@@ -4077,7 +4078,7 @@ print_support_extended_ifa_flags (NMSettingIP6ConfigPrivacy use_tempaddr)
if (s_libnl == -1) {
s_libnl = !!nm_platform_check_support_libnl_extended_ifa_flags ();
- s_kernel = !!nm_platform_check_support_kernel_extended_ifa_flags ();
+ s_kernel = !!nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET);
if (s_libnl && s_kernel) {
nm_log_dbg (LOGD_IP6, "kernel and libnl support extended IFA_FLAGS (needed by NM for IPv6 private addresses)");
@@ -4128,8 +4129,8 @@ nm_device_set_mtu (NMDevice *self, guint32 mtu)
if (priv->ip6_mtu)
nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
- if (priv->mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, priv->mtu);
+ if (priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex))
+ nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu);
}
static void
@@ -4182,7 +4183,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
* from adding a prefix route for this address.
**/
system_support = nm_platform_check_support_libnl_extended_ifa_flags () &&
- nm_platform_check_support_kernel_extended_ifa_flags ();
+ nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET);
}
if (system_support)
@@ -4349,7 +4350,7 @@ addrconf6_start_with_link_ready (NMDevice *self)
g_assert (priv->rdisc);
- if (nm_platform_link_get_ipv6_token (priv->ifindex, &iid)) {
+ if (nm_platform_link_get_ipv6_token (NM_PLATFORM_GET, priv->ifindex, &iid)) {
_LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface);
} else if (!nm_device_get_ip_iface_identifier (self, &iid)) {
_LOGW (LOGD_IP6, "failed to get interface identifier; IPv6 cannot continue");
@@ -4464,7 +4465,7 @@ save_ip6_properties (NMDevice *self)
g_hash_table_remove_all (priv->ip6_saved_properties);
for (i = 0; i < G_N_ELEMENTS (ip6_properties_to_save); i++) {
- value = nm_platform_sysctl_get (nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i]));
+ value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i]));
if (value) {
g_hash_table_insert (priv->ip6_saved_properties,
(char *) ip6_properties_to_save[i],
@@ -4505,7 +4506,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
const char *iface = nm_device_get_ip_iface (self);
char *value;
- if (!nm_platform_check_support_user_ipv6ll ())
+ if (!nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET))
return;
priv->nm_ipv6ll = enable;
@@ -4513,13 +4514,13 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
const char *detail = enable ? "enable" : "disable";
_LOGD (LOGD_IP6, "will %s userland IPv6LL", detail);
- if ( !nm_platform_link_set_user_ipv6ll_enabled (ifindex, enable)
- && nm_platform_get_error () != NM_PLATFORM_ERROR_NOT_FOUND)
+ if ( !nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, enable)
+ && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_NOT_FOUND)
_LOGW (LOGD_IP6, "failed to %s userspace IPv6LL address handling", detail);
if (enable) {
/* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */
- value = nm_platform_sysctl_get (nm_utils_ip6_property_path (iface, "disable_ipv6"));
+ value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (iface, "disable_ipv6"));
if (g_strcmp0 (value, "0") == 0)
nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1");
g_free (value);
@@ -4884,7 +4885,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data)
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
/* Device should be up before we can do anything with it */
- if (!nm_platform_link_is_up (nm_device_get_ip_ifindex (self)))
+ if (!nm_platform_link_is_up (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self)))
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
/* If the device is a slave, then we don't do any IP configuration but we
@@ -5139,14 +5140,14 @@ share_init (void)
char **iter;
int errsv;
- if (!nm_platform_sysctl_set ("/proc/sys/net/ipv4/ip_forward", "1")) {
+ if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_forward", "1")) {
errsv = errno;
nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s",
errsv, strerror (errsv));
return FALSE;
}
- if (!nm_platform_sysctl_set ("/proc/sys/net/ipv4/ip_dynaddr", "1")) {
+ if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_dynaddr", "1")) {
errsv = errno;
nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s",
errsv, strerror (errsv));
@@ -5356,9 +5357,9 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
/* Interface must be IFF_UP before IP config can be applied */
ip_ifindex = nm_device_get_ip_ifindex (self);
- if (!nm_platform_link_is_up (ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
- nm_platform_link_set_up (ip_ifindex);
- if (!nm_platform_link_is_up (ip_ifindex))
+ if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
+ nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex);
+ if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex))
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
}
@@ -5477,9 +5478,9 @@ nm_device_activate_ip6_config_commit (gpointer user_data)
/* Interface must be IFF_UP before IP config can be applied */
ip_ifindex = nm_device_get_ip_ifindex (self);
- if (!nm_platform_link_is_up (ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
- nm_platform_link_set_up (ip_ifindex);
- if (!nm_platform_link_is_up (ip_ifindex))
+ if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_uses_assumed_connection (self)) {
+ nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex);
+ if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex))
_LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self));
}
@@ -5648,7 +5649,7 @@ delete_on_deactivate_link_delete (gpointer user_data)
_LOGD (LOGD_DEVICE, "delete_on_deactivate: cleanup and delete virtual link #%d (id=%u)",
data->ifindex, data->idle_add_id);
- nm_platform_link_delete (data->ifindex);
+ nm_platform_link_delete (NM_PLATFORM_GET, data->ifindex);
g_free (data);
return FALSE;
}
@@ -5782,7 +5783,7 @@ delete_cb (NMDevice *self,
}
/* Authorized */
- nm_platform_link_delete (nm_device_get_ifindex (self));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_device_get_ifindex (self));
dbus_g_method_return (context);
}
@@ -6534,7 +6535,7 @@ is_up (NMDevice *self)
{
int ifindex = nm_device_get_ip_ifindex (self);
- return ifindex > 0 ? nm_platform_link_is_up (ifindex) : TRUE;
+ return ifindex > 0 ? nm_platform_link_is_up (NM_PLATFORM_GET, ifindex) : TRUE;
}
gboolean
@@ -6559,7 +6560,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
do {
g_usleep (200);
- if (!nm_platform_link_refresh (ifindex))
+ if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex))
return FALSE;
device_is_up = nm_device_is_up (self);
} while (!device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until);
@@ -6599,7 +6600,7 @@ check_carrier (NMDevice *self)
int ifindex = nm_device_get_ip_ifindex (self);
if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
- nm_device_set_carrier (self, nm_platform_link_is_connected (ifindex));
+ nm_device_set_carrier (self, nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
}
static gboolean
@@ -6614,9 +6615,9 @@ bring_up (NMDevice *self, gboolean *no_firmware)
return TRUE;
}
- result = nm_platform_link_set_up (ifindex);
+ result = nm_platform_link_set_up (NM_PLATFORM_GET, ifindex);
if (no_firmware)
- *no_firmware = nm_platform_get_error () == NM_PLATFORM_ERROR_NO_FIRMWARE;
+ *no_firmware = nm_platform_get_error (NM_PLATFORM_GET) == NM_PLATFORM_ERROR_NO_FIRMWARE;
/* Store carrier immediately. */
if (result && nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT))
@@ -6646,7 +6647,7 @@ nm_device_take_down (NMDevice *self, gboolean block)
do {
g_usleep (200);
- if (!nm_platform_link_refresh (ifindex))
+ if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex))
return;
device_is_up = nm_device_is_up (self);
} while (device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until);
@@ -6666,7 +6667,7 @@ take_down (NMDevice *self)
int ifindex = nm_device_get_ip_ifindex (self);
if (ifindex > 0)
- return nm_platform_link_set_down (ifindex);
+ return nm_platform_link_set_down (NM_PLATFORM_GET, ifindex);
/* devices without ifindex are always up. */
_LOGD (LOGD_HW, "cannot take down device without ifindex");
@@ -7306,7 +7307,7 @@ cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpoin
gboolean
nm_device_supports_vlans (NMDevice *self)
{
- return nm_platform_link_supports_vlans (nm_device_get_ifindex (self));
+ return nm_platform_link_supports_vlans (NM_PLATFORM_GET, nm_device_get_ifindex (self));
}
/**
@@ -7570,7 +7571,7 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, gboolean deconfig
ifindex = nm_device_get_ip_ifindex (self);
if (ifindex > 0) {
nm_route_manager_route_flush (nm_route_manager_get (), ifindex);
- nm_platform_address_flush (ifindex);
+ nm_platform_address_flush (NM_PLATFORM_GET, ifindex);
}
_cleanup_generic_post (self, deconfigure);
@@ -8241,7 +8242,7 @@ nm_device_update_hw_address (NMDevice *self)
if (ifindex <= 0)
return;
- hwaddr = nm_platform_link_get_address (ifindex, &hwaddrlen);
+ hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddrlen);
if (hwaddrlen) {
if (!priv->hw_addr || !nm_utils_hwaddr_matches (priv->hw_addr, -1, hwaddr, hwaddrlen)) {
@@ -8287,7 +8288,7 @@ nm_device_set_hw_addr (NMDevice *self, const char *addr,
/* Can't change MAC address while device is up */
nm_device_take_down (self, FALSE);
- success = nm_platform_link_set_address (nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len);
+ success = nm_platform_link_set_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len);
if (success) {
/* MAC address succesfully changed; update the current MAC to match */
nm_device_update_hw_address (self);
@@ -8480,11 +8481,11 @@ constructor (GType type,
/* trigger initial ip config change to initialize ip-config */
priv->queued_ip_config_id = g_idle_add (queued_ip_config_change, self);
- if (nm_platform_check_support_user_ipv6ll ()) {
+ if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) {
int ip_ifindex = nm_device_get_ip_ifindex (self);
if (ip_ifindex > 0)
- priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (ip_ifindex);
+ priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, ip_ifindex);
}
return object;
@@ -8524,17 +8525,17 @@ constructed (GObject *object)
}
if (priv->ifindex > 0) {
- priv->is_software = nm_platform_link_is_software (priv->ifindex);
- priv->physical_port_id = nm_platform_link_get_physical_port_id (priv->ifindex);
- priv->dev_id = nm_platform_link_get_dev_id (priv->ifindex);
- priv->mtu = nm_platform_link_get_mtu (priv->ifindex);
+ priv->is_software = nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex);
+ priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex);
+ priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex);
+ priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex);
}
/* Indicate software device in capabilities. */
if (priv->is_software)
priv->capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
/* Enslave ourselves */
- master = nm_platform_link_get_master (priv->ifindex);
+ master = nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex);
if (master)
device_set_master (self, master);
@@ -8681,9 +8682,9 @@ set_property (GObject *object, guint prop_id,
if (g_value_get_string (value)) {
g_free (priv->iface);
priv->iface = g_value_dup_string (value);
- priv->ifindex = nm_platform_link_get_ifindex (priv->iface);
+ priv->ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->iface);
if (priv->ifindex > 0)
- priv->up = nm_platform_link_is_up (priv->ifindex);
+ priv->up = nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex);
}
break;
case PROP_DRIVER:
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 85f7e19ba0..6b58014393 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -618,7 +618,8 @@ enslave_slave (NMDevice *device,
}
}
}
- success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device),
+ success = nm_platform_link_enslave (NM_PLATFORM_GET,
+ nm_device_get_ip_ifindex (device),
nm_device_get_ip_ifindex (slave));
nm_device_bring_up (slave, TRUE, &no_firmware);
@@ -643,7 +644,8 @@ release_slave (NMDevice *device,
gboolean success = TRUE, no_firmware = FALSE;
if (configure) {
- success = nm_platform_link_release (nm_device_get_ip_ifindex (device),
+ success = nm_platform_link_release (NM_PLATFORM_GET,
+ nm_device_get_ip_ifindex (device),
nm_device_get_ip_ifindex (slave));
if (success)
@@ -695,14 +697,14 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error)
iface = nm_connection_get_interface_name (connection);
g_return_val_if_fail (iface != NULL, NULL);
- if ( !nm_platform_team_add (iface)
- && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
+ if ( !nm_platform_team_add (NM_PLATFORM_GET, iface)
+ && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) {
g_set_error (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_CREATION_FAILED,
"failed to create team master interface '%s' for connection '%s': %s",
iface, nm_connection_get_id (connection),
- nm_platform_get_error_msg ());
+ nm_platform_get_error_msg (NM_PLATFORM_GET));
return NULL;
}
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index dc3dfbc659..f8bf2f7d97 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -197,8 +197,8 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel)
{
int ifindex = nm_device_get_ifindex (NM_DEVICE (self));
- if (nm_platform_mesh_get_channel (ifindex) != channel) {
- if (nm_platform_mesh_set_channel (ifindex, channel))
+ if (nm_platform_mesh_get_channel (NM_PLATFORM_GET, ifindex) != channel) {
+ if (nm_platform_mesh_set_channel (NM_PLATFORM_GET, ifindex, channel))
g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL);
}
}
@@ -224,7 +224,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
_mesh_set_channel (self, channel);
ssid = nm_setting_olpc_mesh_get_ssid (s_mesh);
- nm_platform_mesh_set_ssid (nm_device_get_ifindex (device),
+ nm_platform_mesh_set_ssid (NM_PLATFORM_GET,
+ nm_device_get_ifindex (device),
g_bytes_get_data (ssid, NULL),
g_bytes_get_size (ssid));
@@ -453,7 +454,7 @@ constructor (GType type,
self = NM_DEVICE_OLPC_MESH (object);
- if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
+ if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
_LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver");
g_object_unref (object);
return NULL;
@@ -482,7 +483,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_boxed (value, "/");
break;
case PROP_ACTIVE_CHANNEL:
- g_value_set_uint (value, nm_platform_mesh_get_channel (nm_device_get_ifindex (NM_DEVICE (device))));
+ g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device))));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 1361bd89dd..747c021c6d 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -219,7 +219,8 @@ constructor (GType type,
self = NM_DEVICE_WIFI (object);
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
- if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)),
+ if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET,
+ nm_device_get_ifindex (NM_DEVICE (self)),
&priv->capabilities)) {
_LOGW (LOGD_HW | LOGD_WIFI, "failed to initialize WiFi driver");
g_object_unref (object);
@@ -439,14 +440,14 @@ periodic_update (NMDeviceWifi *self)
if (priv->current_ap) {
/* Smooth out the strength to work around crappy drivers */
- percent = nm_platform_wifi_get_quality (ifindex);
+ percent = nm_platform_wifi_get_quality (NM_PLATFORM_GET, ifindex);
if (percent >= 0 || ++priv->invalid_strength_counter > 3) {
nm_ap_set_strength (priv->current_ap, (gint8) percent);
priv->invalid_strength_counter = 0;
}
}
- new_rate = nm_platform_wifi_get_rate (ifindex);
+ new_rate = nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex);
if (new_rate != priv->rate) {
priv->rate = new_rate;
g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_BITRATE);
@@ -533,20 +534,20 @@ deactivate (NMDevice *device)
set_current_ap (self, NULL, TRUE, FALSE);
/* Clear any critical protocol notification in the Wi-Fi stack */
- nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
+ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE);
/* Reset MAC address back to initial address */
if (priv->initial_hw_addr)
nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_WIFI);
- nm_platform_wifi_set_powersave (ifindex, 0);
+ nm_platform_wifi_set_powersave (NM_PLATFORM_GET, ifindex, 0);
/* Ensure we're in infrastructure mode after deactivation; some devices
* (usually older ones) don't scan well in adhoc mode.
*/
- if (nm_platform_wifi_get_mode (ifindex) != NM_802_11_MODE_INFRA) {
+ if (nm_platform_wifi_get_mode (NM_PLATFORM_GET, ifindex) != NM_802_11_MODE_INFRA) {
nm_device_take_down (NM_DEVICE (self), TRUE);
- nm_platform_wifi_set_mode (ifindex, NM_802_11_MODE_INFRA);
+ nm_platform_wifi_set_mode (NM_PLATFORM_GET, ifindex, NM_802_11_MODE_INFRA);
nm_device_bring_up (NM_DEVICE (self), TRUE, NULL);
}
@@ -2513,9 +2514,9 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
return;
if (g_strcmp0 (band, "a") == 0)
- freq = nm_platform_wifi_find_frequency (nm_device_get_ifindex (NM_DEVICE (self)), a_freqs);
+ freq = nm_platform_wifi_find_frequency (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), a_freqs);
else
- freq = nm_platform_wifi_find_frequency (nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs);
+ freq = nm_platform_wifi_find_frequency (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs);
if (!freq)
freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462;
@@ -2589,7 +2590,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
ensure_hotspot_frequency (self, s_wireless, ap);
if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA) {
- nm_platform_wifi_set_powersave (nm_device_get_ifindex (device),
+ nm_platform_wifi_set_powersave (NM_PLATFORM_GET,
+ nm_device_get_ifindex (device),
nm_setting_wireless_get_powersave (s_wireless));
}
@@ -2654,7 +2656,7 @@ act_stage3_ip4_config_start (NMDevice *device,
/* Indicate that a critical protocol is about to start */
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0)
- nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), TRUE);
+ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE);
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
}
@@ -2677,7 +2679,7 @@ act_stage3_ip6_config_start (NMDevice *device,
/* Indicate that a critical protocol is about to start */
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 ||
strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0)
- nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), TRUE);
+ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE);
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason);
}
@@ -2826,7 +2828,7 @@ activation_success_handler (NMDevice *device)
g_assert (connection);
/* Clear any critical protocol notification in the wifi stack */
- nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
+ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE);
/* Clear wireless secrets tries on success */
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
@@ -2847,16 +2849,16 @@ activation_success_handler (NMDevice *device)
guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
gs_free char *bssid_str = NULL;
- if ( nm_platform_wifi_get_bssid (ifindex, bssid)
+ if ( nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid)
&& nm_ethernet_address_is_valid (bssid, ETH_ALEN)) {
bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
nm_ap_set_address (priv->current_ap, bssid_str);
}
}
if (!nm_ap_get_freq (priv->current_ap))
- nm_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (ifindex));
+ nm_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex));
if (!nm_ap_get_max_bitrate (priv->current_ap))
- nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (ifindex));
+ nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex));
}
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (priv->current_ap));
@@ -2880,7 +2882,7 @@ activation_failure_handler (NMDevice *device)
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
/* Clear any critical protocol notification in the wifi stack */
- nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE);
+ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE);
}
static void
@@ -2930,7 +2932,7 @@ device_state_changed (NMDevice *device,
break;
case NM_DEVICE_STATE_IP_CHECK:
/* Clear any critical protocol notification in the wifi stack */
- nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE);
+ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE);
break;
case NM_DEVICE_STATE_ACTIVATED:
activation_success_handler (device);
diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c
index 8129a64222..2c07b36f65 100644
--- a/src/devices/wwan/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -747,7 +747,7 @@ static_stage3_ip4_done (NMModemBroadband *self)
data_port = mm_bearer_get_interface (self->priv->bearer);
g_assert (data_port);
- config = nm_ip4_config_new (nm_platform_link_get_ifindex (data_port));
+ config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port));
memset (&address, 0, sizeof (address));
address.address = address_network;
@@ -840,7 +840,7 @@ stage3_ip6_done (NMModemBroadband *self)
data_port = mm_bearer_get_interface (self->priv->bearer);
g_assert (data_port);
- config = nm_ip6_config_new (nm_platform_link_get_ifindex (data_port));
+ config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port));
address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv6_config);
nm_ip6_config_add_address (config, &address);
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c
index bbb229d930..3385a6fd3b 100644
--- a/src/devices/wwan/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -616,7 +616,7 @@ nm_modem_ip4_pre_commit (NMModem *modem,
g_assert (address);
if (address->plen == 32)
- nm_platform_link_set_noarp (nm_device_get_ip_ifindex (device));
+ nm_platform_link_set_noarp (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device));
}
}
@@ -914,8 +914,8 @@ deactivate_cleanup (NMModem *self, NMDevice *device)
ifindex = nm_device_get_ip_ifindex (device);
if (ifindex > 0) {
nm_route_manager_route_flush (nm_route_manager_get (), ifindex);
- nm_platform_address_flush (ifindex);
- nm_platform_link_set_down (ifindex);
+ nm_platform_address_flush (NM_PLATFORM_GET, ifindex);
+ nm_platform_link_set_down (NM_PLATFORM_GET, ifindex);
}
}
}
diff --git a/src/main.c b/src/main.c
index e19fc6bbed..a5851dc558 100644
--- a/src/main.c
+++ b/src/main.c
@@ -478,7 +478,7 @@ main (int argc, char *argv[])
* physical interfaces.
*/
nm_log_dbg (LOGD_CORE, "setting up local loopback");
- nm_platform_link_set_up (nm_platform_link_get_ifindex ("lo"));
+ nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "lo"));
success = TRUE;
diff --git a/src/nm-dcb.c b/src/nm-dcb.c
index 0b18ca7f2b..8bf3858a3d 100644
--- a/src/nm-dcb.c
+++ b/src/nm-dcb.c
@@ -354,7 +354,7 @@ carrier_wait (const char *iface, guint secs, gboolean up)
g_return_if_fail (iface != NULL);
- ifindex = nm_platform_link_get_ifindex (iface);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, iface);
if (ifindex > 0) {
/* To work around driver quirks and lldpad handling of carrier status,
* we must wait a short period of time to see if the carrier goes
@@ -365,9 +365,9 @@ carrier_wait (const char *iface, guint secs, gboolean up)
nm_log_dbg (LOGD_DCB, "(%s): cleanup waiting for carrier %s",
iface, up ? "up" : "down");
g_usleep (G_USEC_PER_SEC / 4);
- while (nm_platform_link_is_connected (ifindex) != up && count-- > 0) {
+ while (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex) != up && count-- > 0) {
g_usleep (G_USEC_PER_SEC / 10);
- nm_platform_link_refresh (ifindex);
+ nm_platform_link_refresh (NM_PLATFORM_GET, ifindex);
}
}
}
diff --git a/src/nm-default-route-manager.c b/src/nm-default-route-manager.c
index 1eda7e6e94..c04dd96fa7 100644
--- a/src/nm-default-route-manager.c
+++ b/src/nm-default-route-manager.c
@@ -256,7 +256,8 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g
return FALSE;
if (vtable->vt->is_ip4) {
- success = nm_platform_ip4_route_add (entry->route.rx.ifindex,
+ success = nm_platform_ip4_route_add (NM_PLATFORM_GET,
+ entry->route.rx.ifindex,
entry->route.rx.source,
0,
0,
@@ -265,7 +266,8 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g
entry->effective_metric,
entry->route.rx.mss);
} else {
- success = nm_platform_ip6_route_add (entry->route.rx.ifindex,
+ success = nm_platform_ip6_route_add (NM_PLATFORM_GET,
+ entry->route.rx.ifindex,
entry->route.rx.source,
in6addr_any,
0,
@@ -290,7 +292,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self,
gboolean changed = FALSE;
/* prune all other default routes from this device. */
- routes = vtable->vt->route_get_all (0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
+ routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
for (i = 0; i < routes->len; i++) {
const NMPlatformIPRoute *route;
@@ -322,7 +324,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self,
*/
if ( !entry
&& (has_ifindex_synced || ifindex_to_flush == route->ifindex)) {
- vtable->vt->route_delete_default (route->ifindex, route->metric);
+ vtable->vt->route_delete_default (NM_PLATFORM_GET, route->ifindex, route->metric);
changed = TRUE;
}
}
@@ -452,7 +454,7 @@ _resync_all (const VTableIP *vtable, NMDefaultRouteManager *self, const Entry *c
entries = vtable->get_entries (priv);
- routes = vtable->vt->route_get_all (0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
+ routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
assumed_metrics = _get_assumed_interface_metrics (vtable, self, routes);
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 4892ddb006..756af2a1b4 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -146,7 +146,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
* from adding a prefix route for this address.
**/
system_support = nm_platform_check_support_libnl_extended_ifa_flags () &&
- nm_platform_check_support_kernel_extended_ifa_flags ();
+ nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET);
}
if (system_support)
@@ -233,14 +233,14 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
char val[16];
g_snprintf (val, sizeof (val), "%d", rdisc->hop_limit);
- nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "hop_limit"), val);
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "hop_limit"), val);
}
if (changed & NM_RDISC_CONFIG_MTU) {
char val[16];
g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
- nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val);
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val);
}
existing = nm_ip6_config_capture (ifindex, FALSE, global_opt.tempaddr);
@@ -426,7 +426,7 @@ main (int argc, char *argv[])
/* Set up platform interaction layer */
nm_linux_platform_setup ();
- tmp = nm_platform_link_get_address (ifindex, &hwaddr_len);
+ tmp = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len);
if (tmp) {
hwaddr = g_byte_array_sized_new (hwaddr_len);
g_byte_array_append (hwaddr, tmp, hwaddr_len);
@@ -445,7 +445,7 @@ main (int argc, char *argv[])
}
if (global_opt.dhcp4_address) {
- nm_platform_sysctl_set (nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1");
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1");
dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (),
global_opt.ifname,
@@ -467,7 +467,7 @@ main (int argc, char *argv[])
}
if (global_opt.slaac) {
- nm_platform_link_set_user_ipv6ll_enabled (ifindex, TRUE);
+ nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, TRUE);
rdisc = nm_lndp_rdisc_new (ifindex, global_opt.ifname);
g_assert (rdisc);
@@ -475,10 +475,10 @@ main (int argc, char *argv[])
if (iid)
nm_rdisc_set_iid (rdisc, *iid);
- nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1");
- nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0");
- nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0");
- nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0");
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1");
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0");
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0");
+ nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0");
g_signal_connect (rdisc,
NM_RDISC_CONFIG_CHANGED,
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index 10e2b62c62..8b1596dd0d 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -196,7 +196,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
gboolean has_gateway = FALSE;
/* Slaves have no IP configuration */
- if (nm_platform_link_get_master (ifindex) > 0)
+ if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0)
return NULL;
config = nm_ip4_config_new (ifindex);
@@ -205,8 +205,8 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
- priv->addresses = nm_platform_ip4_address_get_all (ifindex);
- priv->routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
+ priv->routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
/* Extract gateway from default route */
old_gateway = priv->gateway;
@@ -270,7 +270,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
g_return_val_if_fail (config != NULL, FALSE);
/* Addresses */
- nm_platform_ip4_address_sync (ifindex, priv->addresses, default_route_metric);
+ nm_platform_ip4_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, default_route_metric);
/* Routes */
{
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index 4df7e2996f..2077af81b3 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -310,7 +310,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
gboolean notify_nameservers = FALSE;
/* Slaves have no IP configuration */
- if (nm_platform_link_get_master (ifindex) > 0)
+ if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0)
return NULL;
config = nm_ip6_config_new (ifindex);
@@ -319,8 +319,8 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
- priv->addresses = nm_platform_ip6_address_get_all (ifindex);
- priv->routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
+ priv->routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
/* Extract gateway from default route */
old_gateway = priv->gateway;
@@ -387,7 +387,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
g_return_val_if_fail (config != NULL, FALSE);
/* Addresses */
- nm_platform_ip6_address_sync (ifindex, priv->addresses, TRUE);
+ nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE);
/* Routes */
{
diff --git a/src/nm-manager.c b/src/nm-manager.c
index d4312a2084..f8815b6481 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1090,7 +1090,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection, GError
*/
priv->ignore_link_added_cb++;
- nm_owned = !nm_platform_link_exists (iface);
+ nm_owned = !nm_platform_link_exists (NM_PLATFORM_GET, iface);
for (iter = priv->factories; iter; iter = iter->next) {
device = nm_device_factory_create_virtual_device_for_connection (NM_DEVICE_FACTORY (iter->data),
@@ -1572,13 +1572,13 @@ get_existing_connection (NMManager *manager, NMDevice *device, gboolean *out_gen
nm_device_capture_initial_config (device);
if (ifindex) {
- int master_ifindex = nm_platform_link_get_master (ifindex);
+ int master_ifindex = nm_platform_link_get_master (NM_PLATFORM_GET, ifindex);
if (master_ifindex) {
master = nm_manager_get_device_by_ifindex (manager, master_ifindex);
if (!master) {
nm_log_dbg (LOGD_DEVICE, "(%s): cannot generate connection for slave before its master (%s/%d)",
- nm_device_get_iface (device), nm_platform_link_get_name (master_ifindex), master_ifindex);
+ nm_device_get_iface (device), nm_platform_link_get_name (NM_PLATFORM_GET, master_ifindex), master_ifindex);
return NULL;
}
if (!nm_device_get_act_request (master)) {
@@ -1870,7 +1870,7 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
user_unmanaged = nm_device_spec_match_list (device, unmanaged_specs);
nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_USER, user_unmanaged);
- if (nm_platform_link_get_unmanaged (nm_device_get_ifindex (device), &platform_unmanaged))
+ if (nm_platform_link_get_unmanaged (NM_PLATFORM_GET, nm_device_get_ifindex (device), &platform_unmanaged))
nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_DEFAULT, platform_unmanaged);
sleeping = manager_sleeping (self);
@@ -3665,7 +3665,7 @@ done:
static gboolean
device_is_wake_on_lan (NMDevice *device)
{
- return nm_platform_link_get_wake_on_lan (nm_device_get_ip_ifindex (device));
+ return nm_platform_link_get_wake_on_lan (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device));
}
static void
@@ -4260,7 +4260,7 @@ nm_manager_start (NMManager *self)
for (iter = priv->factories; iter; iter = iter->next)
nm_device_factory_start (iter->data);
- nm_platform_query_devices ();
+ nm_platform_query_devices (NM_PLATFORM_GET);
/*
* Connections added before the manager is started do not emit
diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c
index d97b896d88..7c9d688392 100644
--- a/src/nm-route-manager.c
+++ b/src/nm-route-manager.c
@@ -358,7 +358,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
NMPlatformIPXRoute *cur_ipx_route;
ipx_routes = vtable->vt->is_ip4 ? &priv->ip4_routes : &priv->ip6_routes;
- plat_routes = vtable->vt->route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
+ plat_routes = vtable->vt->route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
plat_routes_idx = _route_index_create (vtable, plat_routes);
known_routes_idx = _route_index_create (vtable, known_routes);
@@ -494,7 +494,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
/* if @cur_ipx_route is not equal to @plat_route, the route must be deleted. */
if (!(cur_ipx_route && route_id_cmp_result == 0))
- vtable->vt->route_delete (ifindex, cur_plat_route);
+ vtable->vt->route_delete (NM_PLATFORM_GET, ifindex, cur_plat_route);
cur_plat_route = _get_next_plat_route (plat_routes_idx, FALSE, &i_plat_routes);
}
@@ -515,7 +515,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
* device routes, on the second the others (gateway routes). */
continue;
}
- vtable->vt->route_add (0, rest_route, 0);
+ vtable->vt->route_add (NM_PLATFORM_GET, 0, rest_route, 0);
}
}
g_array_unref (to_restore_routes);
@@ -560,7 +560,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
|| !_route_equals_ignoring_ifindex (vtable, cur_plat_route, cur_ipx_route)) {
gboolean s;
- s = vtable->vt->route_add (ifindex, cur_ipx_route, 0);
+ s = vtable->vt->route_add (NM_PLATFORM_GET, ifindex, cur_ipx_route, 0);
if (!s && cur_ipx_route->rx.source < NM_IP_CONFIG_SOURCE_USER) {
_LOGD (vtable->vt->addr_family, "ignore error adding IPv%c route to kernel: %s",
vtable->vt->is_ip4 ? '4' : '6',
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 07b5dda1ee..0fedb7275d 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -918,7 +918,7 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink, const char
NMPlatformTunProperties props;
guint flags;
- if (nm_platform_tun_get_properties (rtnl_link_get_ifindex (rtnllink), &props)) {
+ if (nm_platform_tun_get_properties (platform, rtnl_link_get_ifindex (rtnllink), &props)) {
if (!g_strcmp0 (props.mode, "tap"))
return_type (NM_LINK_TYPE_TAP, "tap");
if (!g_strcmp0 (props.mode, "tun"))
@@ -2632,7 +2632,7 @@ supports_mii_carrier_detect (const char *ifname)
static gboolean
link_supports_carrier_detect (NMPlatform *platform, int ifindex)
{
- const char *name = nm_platform_link_get_name (ifindex);
+ const char *name = nm_platform_link_get_name (platform, ifindex);
if (!name)
return FALSE;
@@ -2648,7 +2648,7 @@ static gboolean
link_supports_vlans (NMPlatform *platform, int ifindex)
{
auto_nl_object struct rtnl_link *rtnllink = link_get (platform, ifindex);
- const char *name = nm_platform_link_get_name (ifindex);
+ const char *name = nm_platform_link_get_name (platform, ifindex);
gs_free struct ethtool_gfeatures *features = NULL;
int idx, block, bit, size;
@@ -2746,7 +2746,7 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
const char *ifname;
char *path, *id;
- ifname = nm_platform_link_get_name (ifindex);
+ ifname = nm_platform_link_get_name (platform, ifindex);
if (!ifname)
return NULL;
@@ -2766,7 +2766,7 @@ link_get_dev_id (NMPlatform *platform, int ifindex)
gs_free char *path = NULL, *id = NULL;
gint64 int_val;
- ifname = nm_platform_link_get_name (ifindex);
+ ifname = nm_platform_link_get_name (platform, ifindex);
if (!ifname)
return 0;
@@ -2879,10 +2879,10 @@ link_get_master (NMPlatform *platform, int slave)
}
static char *
-link_option_path (int master, const char *category, const char *option)
+link_option_path (NMPlatform *platform, int master, const char *category, const char *option)
{
- const char *name = nm_platform_link_get_name (master);
-
+ const char *name = nm_platform_link_get_name (platform, master);
+
if (!name || !category || !option)
return NULL;
@@ -2893,19 +2893,19 @@ link_option_path (int master, const char *category, const char *option)
}
static gboolean
-link_set_option (int master, const char *category, const char *option, const char *value)
+link_set_option (NMPlatform *platform, int master, const char *category, const char *option, const char *value)
{
- gs_free char *path = link_option_path (master, category, option);
+ gs_free char *path = link_option_path (platform, master, category, option);
- return path && nm_platform_sysctl_set (path, value);
+ return path && nm_platform_sysctl_set (platform, path, value);
}
static char *
-link_get_option (int master, const char *category, const char *option)
+link_get_option (NMPlatform *platform, int master, const char *category, const char *option)
{
- gs_free char *path = link_option_path (master, category, option);
+ gs_free char *path = link_option_path (platform, master, category, option);
- return path ? nm_platform_sysctl_get (path) : NULL;
+ return path ? nm_platform_sysctl_get (platform, path) : NULL;
}
static const char *
@@ -2944,25 +2944,25 @@ slave_category (NMPlatform *platform, int slave)
static gboolean
master_set_option (NMPlatform *platform, int master, const char *option, const char *value)
{
- return link_set_option (master, master_category (platform, master), option, value);
+ return link_set_option (platform, master, master_category (platform, master), option, value);
}
static char *
master_get_option (NMPlatform *platform, int master, const char *option)
{
- return link_get_option (master, master_category (platform, master), option);
+ return link_get_option (platform, master, master_category (platform, master), option);
}
static gboolean
slave_set_option (NMPlatform *platform, int slave, const char *option, const char *value)
{
- return link_set_option (slave, slave_category (platform, slave), option, value);
+ return link_set_option (platform, slave, slave_category (platform, slave), option, value);
}
static char *
slave_get_option (NMPlatform *platform, int slave, const char *option)
{
- return link_get_option (slave, slave_category (platform, slave), option);
+ return link_get_option (platform, slave, slave_category (platform, slave), option);
}
static gboolean
@@ -2972,12 +2972,12 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key)
char *path, *id;
gboolean success;
- parent_name = nm_platform_link_get_name (parent);
+ parent_name = nm_platform_link_get_name (platform, parent);
g_return_val_if_fail (parent_name != NULL, FALSE);
path = g_strdup_printf ("/sys/class/net/%s/create_child", ASSERT_VALID_PATH_COMPONENT (parent_name));
id = g_strdup_printf ("0x%04x", p_key);
- success = nm_platform_sysctl_set (path, id);
+ success = nm_platform_sysctl_set (platform, path, id);
g_free (id);
g_free (path);
@@ -2998,7 +2998,7 @@ veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties
gs_free struct ethtool_stats *stats = NULL;
int peer_ifindex_stat;
- ifname = nm_platform_link_get_name (ifindex);
+ ifname = nm_platform_link_get_name (platform, ifindex);
if (!ifname)
return FALSE;
@@ -3031,13 +3031,13 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
props->owner = -1;
props->group = -1;
- ifname = nm_platform_link_get_name (ifindex);
+ ifname = nm_platform_link_get_name (platform, ifindex);
if (!ifname || !nm_utils_iface_valid_name (ifname))
return FALSE;
ifname = ASSERT_VALID_PATH_COMPONENT (ifname);
path = g_strdup_printf ("/sys/class/net/%s/owner", ifname);
- val = nm_platform_sysctl_get (path);
+ val = nm_platform_sysctl_get (platform, path);
g_free (path);
if (val) {
props->owner = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
@@ -3048,7 +3048,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
success = FALSE;
path = g_strdup_printf ("/sys/class/net/%s/group", ifname);
- val = nm_platform_sysctl_get (path);
+ val = nm_platform_sysctl_get (platform, path);
g_free (path);
if (val) {
props->group = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
@@ -3059,7 +3059,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
success = FALSE;
path = g_strdup_printf ("/sys/class/net/%s/tun_flags", ifname);
- val = nm_platform_sysctl_get (path);
+ val = nm_platform_sysctl_get (platform, path);
g_free (path);
if (val) {
gint64 flags;
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 6397061b00..1bc907b667 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -58,8 +58,27 @@ static guint signals[LAST_SIGNAL] = { 0 };
/******************************************************************/
/* Singleton NMPlatform subclass instance and cached class object */
-static NMPlatform *platform = NULL;
-static NMPlatformClass *klass = NULL;
+static NMPlatform *singleton_instance = NULL;
+
+/* Just always initialize a @klass instance. NM_PLATFORM_GET_CLASS()
+ * is only a plain read on the self instance, which the compiler
+ * like can optimize out.
+ */
+#define _CHECK_SELF_VOID(self, klass) \
+ NMPlatformClass *klass; \
+ do { \
+ g_return_if_fail (NM_IS_PLATFORM (self)); \
+ klass = NM_PLATFORM_GET_CLASS (self); \
+ (void) klass; \
+ } while (0)
+
+#define _CHECK_SELF(self, klass, err_val) \
+ NMPlatformClass *klass; \
+ do { \
+ g_return_val_if_fail (NM_IS_PLATFORM (self), err_val); \
+ klass = NM_PLATFORM_GET_CLASS (self); \
+ (void) klass; \
+ } while (0)
/**
* nm_platform_setup:
@@ -82,16 +101,17 @@ void
nm_platform_setup (GType type)
{
gboolean status;
+ NMPlatformClass *klass;
- g_assert (platform == NULL);
+ g_assert (singleton_instance == NULL);
- platform = g_object_new (type, NULL);
- g_assert (NM_IS_PLATFORM (platform));
+ singleton_instance = g_object_new (type, NULL);
+ g_assert (NM_IS_PLATFORM (singleton_instance));
- klass = NM_PLATFORM_GET_CLASS (platform);
+ klass = NM_PLATFORM_GET_CLASS (singleton_instance);
g_assert (klass->setup);
- status = klass->setup (platform);
+ status = klass->setup (singleton_instance);
g_assert (status);
}
@@ -103,14 +123,15 @@ nm_platform_setup (GType type)
void
nm_platform_free (void)
{
- g_assert (platform);
+ g_assert (singleton_instance);
- g_object_unref (platform);
- platform = NULL;
+ g_object_unref (singleton_instance);
+ singleton_instance = NULL;
}
/**
* nm_platform_get:
+ * @self: platform instance
*
* Retrieve #NMPlatform singleton. Use this whenever you want to connect to
* #NMPlatform signals. It is an error to call it before nm_*_platform_setup()
@@ -119,30 +140,34 @@ nm_platform_free (void)
* Returns: (transfer none): The #NMPlatform singleton reference.
*/
NMPlatform *
-nm_platform_get (void)
+nm_platform_get ()
{
- g_assert (platform);
+ g_assert (singleton_instance);
- return platform;
+ return singleton_instance;
}
/******************************************************************/
/**
* nm_platform_set_error:
+ * @self: platform instance
* @error: The error code
*
- * Convenience function to falsify platform->error. It can be used for example
+ * Convenience function to falsify self->error. It can be used for example
* by functions that want to save the error, execute some operations and
* restore it.
*/
-void nm_platform_set_error (NMPlatformError error)
+void nm_platform_set_error (NMPlatform *self, NMPlatformError error)
{
- platform->error = error;
+ _CHECK_SELF_VOID (self, klass);
+
+ self->error = error;
}
/**
* nm_platform_get_error:
+ * @self: platform instance
*
* Convenience function to quickly retrieve the error code of the last
* operation.
@@ -150,24 +175,25 @@ void nm_platform_set_error (NMPlatformError error)
* Returns: Integer error code.
*/
NMPlatformError
-nm_platform_get_error (void)
+nm_platform_get_error (NMPlatform *self)
{
- g_assert (platform);
+ _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_NONE);
- return platform->error;
+ return self->error;
}
/**
* nm_platform_get_error_message:
+ * @self: platform instance
*
* Returns: Static human-readable string for the error. Don't free.
*/
const char *
-nm_platform_get_error_msg (void)
+nm_platform_get_error_msg (NMPlatform *self)
{
- g_assert (platform);
+ _CHECK_SELF (self, klass, NULL);
- switch (platform->error) {
+ switch (self->error) {
case NM_PLATFORM_ERROR_NONE:
return "unknown error";
case NM_PLATFORM_ERROR_NOT_FOUND:
@@ -186,10 +212,10 @@ nm_platform_get_error_msg (void)
}
static void
-reset_error (void)
+reset_error (NMPlatform *self)
{
- g_assert (platform);
- platform->error = NM_PLATFORM_ERROR_NONE;
+ g_assert (self);
+ self->error = NM_PLATFORM_ERROR_NONE;
}
#define IFA_F_MANAGETEMPADDR_STR "mngtmpaddr"
@@ -209,28 +235,28 @@ nm_platform_check_support_libnl_extended_ifa_flags ()
}
gboolean
-nm_platform_check_support_kernel_extended_ifa_flags ()
+nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self)
{
- g_return_val_if_fail (NM_IS_PLATFORM (platform), FALSE);
+ _CHECK_SELF (self, klass, FALSE);
if (!klass->check_support_kernel_extended_ifa_flags)
return FALSE;
- return klass->check_support_kernel_extended_ifa_flags (platform);
+ return klass->check_support_kernel_extended_ifa_flags (self);
}
gboolean
-nm_platform_check_support_user_ipv6ll (void)
+nm_platform_check_support_user_ipv6ll (NMPlatform *self)
{
static int supported = -1;
- g_return_val_if_fail (NM_IS_PLATFORM (platform), FALSE);
+ _CHECK_SELF (self, klass, FALSE);
if (!klass->check_support_user_ipv6ll)
return FALSE;
if (supported < 0)
- supported = klass->check_support_user_ipv6ll (platform) ? 1 : 0;
+ supported = klass->check_support_user_ipv6ll (self) ? 1 : 0;
return !!supported;
}
@@ -238,6 +264,7 @@ nm_platform_check_support_user_ipv6ll (void)
/**
* nm_platform_sysctl_set:
+ * @self: platform instance
* @path: Absolute option path
* @value: Value to write
*
@@ -248,36 +275,42 @@ nm_platform_check_support_user_ipv6ll (void)
* Returns: %TRUE on success.
*/
gboolean
-nm_platform_sysctl_set (const char *path, const char *value)
+nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
g_return_val_if_fail (path, FALSE);
g_return_val_if_fail (value, FALSE);
g_return_val_if_fail (klass->sysctl_set, FALSE);
- return klass->sysctl_set (platform, path, value);
+ reset_error (self);
+
+ return klass->sysctl_set (self, path, value);
}
/**
* nm_platform_sysctl_get:
+ * @self: platform instance
* @path: Absolute path to sysctl
*
* Returns: (transfer full): Contents of the virtual sysctl file.
*/
char *
-nm_platform_sysctl_get (const char *path)
+nm_platform_sysctl_get (NMPlatform *self, const char *path)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
g_return_val_if_fail (path, NULL);
g_return_val_if_fail (klass->sysctl_get, NULL);
- return klass->sysctl_get (platform, path);
+ reset_error (self);
+
+ return klass->sysctl_get (self, path);
}
/**
* nm_platform_sysctl_get_int32:
+ * @self: platform instance
* @path: Absolute path to sysctl
* @fallback: default value, if the content of path could not be read
* as decimal integer.
@@ -287,13 +320,14 @@ nm_platform_sysctl_get (const char *path)
* value, on success %errno will be set to zero.
*/
gint32
-nm_platform_sysctl_get_int32 (const char *path, gint32 fallback)
+nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback)
{
- return nm_platform_sysctl_get_int_checked (path, 10, G_MININT32, G_MAXINT32, fallback);
+ return nm_platform_sysctl_get_int_checked (self, path, 10, G_MININT32, G_MAXINT32, fallback);
}
/**
* nm_platform_sysctl_get_int_checked:
+ * @self: platform instance
* @path: Absolute path to sysctl
* @base: base of numeric conversion
* @min: minimal value that is still valid
@@ -308,15 +342,17 @@ nm_platform_sysctl_get_int32 (const char *path, gint32 fallback)
* (inclusive) or @fallback.
*/
gint64
-nm_platform_sysctl_get_int_checked (const char *path, guint base, gint64 min, gint64 max, gint64 fallback)
+nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint base, gint64 min, gint64 max, gint64 fallback)
{
char *value = NULL;
gint32 ret;
+ _CHECK_SELF (self, klass, fallback);
+
g_return_val_if_fail (path, fallback);
if (path)
- value = nm_platform_sysctl_get (path);
+ value = nm_platform_sysctl_get (self, path);
if (!value) {
errno = EINVAL;
@@ -332,21 +368,24 @@ nm_platform_sysctl_get_int_checked (const char *path, guint base, gint64 min, gi
/**
* nm_platform_query_devices:
+ * self: platform instance
*
* Emit #NMPlatform:link-changed ADDED signals for all currently-known links.
* Should only be called at startup.
*/
void
-nm_platform_query_devices (void)
+nm_platform_query_devices (NMPlatform *self)
{
GArray *links_array;
NMPlatformLink *links;
int i;
- links_array = nm_platform_link_get_all ();
+ _CHECK_SELF_VOID (self, klass);
+
+ links_array = nm_platform_link_get_all (self);
links = (NMPlatformLink *) links_array->data;
for (i = 0; i < links_array->len; i++) {
- g_signal_emit (platform, signals[SIGNAL_LINK_CHANGED], 0,
+ g_signal_emit (self, signals[SIGNAL_LINK_CHANGED], 0,
links[i].ifindex, &links[i], NM_PLATFORM_SIGNAL_ADDED,
NM_PLATFORM_REASON_INTERNAL);
}
@@ -355,23 +394,25 @@ nm_platform_query_devices (void)
/**
* nm_platform_link_get_all:
+ * self: platform instance
*
* Retrieve a snapshot of configuration for all links at once. The result is
* owned by the caller and should be freed with g_array_unref().
*/
GArray *
-nm_platform_link_get_all (void)
+nm_platform_link_get_all (NMPlatform *self)
{
GArray *links, *result;
guint i, j, nresult;
GHashTable *unseen;
NMPlatformLink *item;
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (klass->link_get_all, NULL);
- links = klass->link_get_all (platform);
+ links = klass->link_get_all (self);
if (!links || links->len == 0)
return links;
@@ -460,6 +501,7 @@ nm_platform_link_get_all (void)
/**
* nm_platform_link_get:
+ * @self: platform instance
* @ifindex: ifindex of the link
* @link: (out): output NMPlatformLink structure.
*
@@ -470,121 +512,135 @@ nm_platform_link_get_all (void)
* If the link does not exist, the content of @link is undefined.
**/
gboolean
-nm_platform_link_get (int ifindex, NMPlatformLink *link)
+nm_platform_link_get (NMPlatform *self, int ifindex, NMPlatformLink *link)
{
+ _CHECK_SELF (self, klass, FALSE);
+
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (link, FALSE);
g_return_val_if_fail (klass->link_get, FALSE);
- return !!klass->link_get (platform, ifindex, link);
+ return !!klass->link_get (self, ifindex, link);
}
/**
* nm_platform_link_add:
+ * @self: platform instance
* @name: Interface name
* @type: Interface type
* @address: (allow-none): set the mac address of the link
* @address_len: the length of the @address
*
- * Add a software interface. Sets platform->error to NM_PLATFORM_ERROR_EXISTS
+ * Add a software interface. Sets self->error to NM_PLATFORM_ERROR_EXISTS
* if interface is already already exists. Any link-changed ADDED signal will be
* emitted directly, before this function finishes.
*/
static gboolean
-nm_platform_link_add (const char *name, NMLinkType type, const void *address, size_t address_len)
+nm_platform_link_add (NMPlatform *self, const char *name, NMLinkType type, const void *address, size_t address_len)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (name, FALSE);
g_return_val_if_fail (klass->link_add, FALSE);
g_return_val_if_fail ( (address != NULL) ^ (address_len == 0) , FALSE);
- if (nm_platform_link_exists (name)) {
+ if (nm_platform_link_exists (self, name)) {
debug ("link: already exists");
- platform->error = NM_PLATFORM_ERROR_EXISTS;
+ self->error = NM_PLATFORM_ERROR_EXISTS;
return FALSE;
}
- return klass->link_add (platform, name, type, address, address_len);
+ return klass->link_add (self, name, type, address, address_len);
}
/**
* nm_platform_dummy_add:
+ * @self: platform instance
* @name: New interface name
*
* Create a software ethernet-like interface
*/
gboolean
-nm_platform_dummy_add (const char *name)
+nm_platform_dummy_add (NMPlatform *self, const char *name)
{
g_return_val_if_fail (name, FALSE);
debug ("link: adding dummy '%s'", name);
- return nm_platform_link_add (name, NM_LINK_TYPE_DUMMY, NULL, 0);
+ return nm_platform_link_add (self, name, NM_LINK_TYPE_DUMMY, NULL, 0);
}
/**
* nm_platform_link_exists:
+ * @self: platform instance
* @name: Interface name
*
* Returns: %TRUE if an interface of this name exists, %FALSE otherwise.
*/
gboolean
-nm_platform_link_exists (const char *name)
+nm_platform_link_exists (NMPlatform *self, const char *name)
{
- int ifindex = nm_platform_link_get_ifindex (name);
+ int ifindex;
- reset_error();
+ _CHECK_SELF (self, klass, FALSE);
+
+ ifindex = nm_platform_link_get_ifindex (self, name);
+
+ reset_error (self);
return ifindex > 0;
}
/**
* nm_platform_link_delete:
+ * @self: platform instance
* @ifindex: Interface index
*
- * Delete a software interface. Sets platform->error to
+ * Delete a software interface. Sets self->error to
* NM_PLATFORM_ERROR_NOT_FOUND if ifindex not available.
*/
gboolean
-nm_platform_link_delete (int ifindex)
+nm_platform_link_delete (NMPlatform *self, int ifindex)
{
const char *name;
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (klass->link_delete, FALSE);
- name = nm_platform_link_get_name (ifindex);
+ name = nm_platform_link_get_name (self, ifindex);
if (!name)
return FALSE;
debug ("link: deleting '%s' (%d)", name, ifindex);
- return klass->link_delete (platform, ifindex);
+ return klass->link_delete (self, ifindex);
}
/**
* nm_platform_link_get_index:
+ * @self: platform instance
* @name: Interface name
*
* Returns: The interface index corresponding to the given interface name
* or 0. Inteface name is owned by #NMPlatform, don't free it.
*/
int
-nm_platform_link_get_ifindex (const char *name)
+nm_platform_link_get_ifindex (NMPlatform *self, const char *name)
{
int ifindex;
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (name, 0);
g_return_val_if_fail (klass->link_get_ifindex, 0);
- ifindex = klass->link_get_ifindex (platform, name);
+ ifindex = klass->link_get_ifindex (self, name);
if (!ifindex) {
debug ("link not found: %s", name);
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ self->error = NM_PLATFORM_ERROR_NOT_FOUND;
}
return ifindex;
@@ -592,25 +648,27 @@ nm_platform_link_get_ifindex (const char *name)
/**
* nm_platform_link_get_name:
+ * @self: platform instance
* @name: Interface name
*
* Returns: The interface name corresponding to the given interface index
* or %NULL.
*/
const char *
-nm_platform_link_get_name (int ifindex)
+nm_platform_link_get_name (NMPlatform *self, int ifindex)
{
const char *name;
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (klass->link_get_name, NULL);
- name = klass->link_get_name (platform, ifindex);
+ name = klass->link_get_name (self, ifindex);
if (!name) {
debug ("link not found: %d", ifindex);
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ self->error = NM_PLATFORM_ERROR_NOT_FOUND;
return FALSE;
}
@@ -619,23 +677,26 @@ nm_platform_link_get_name (int ifindex)
/**
* nm_platform_link_get_type:
+ * @self: platform instance
* @ifindex: Interface index.
*
* Returns: Link type constant as defined in nm-platform.h. On error,
* NM_LINK_TYPE_NONE is returned.
*/
NMLinkType
-nm_platform_link_get_type (int ifindex)
+nm_platform_link_get_type (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NM_LINK_TYPE_NONE);
+ reset_error (self);
g_return_val_if_fail (klass->link_get_type, NM_LINK_TYPE_NONE);
- return klass->link_get_type (platform, ifindex);
+ return klass->link_get_type (self, ifindex);
}
/**
* nm_platform_link_get_type_name:
+ * @self: platform instance
* @ifindex: Interface index.
*
* Returns: A string describing the type of link. In some cases this
@@ -643,17 +704,19 @@ nm_platform_link_get_type (int ifindex)
* other cases it may not. On error, %NULL is returned.
*/
const char *
-nm_platform_link_get_type_name (int ifindex)
+nm_platform_link_get_type_name (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (klass->link_get_type_name, NULL);
- return klass->link_get_type_name (platform, ifindex);
+ return klass->link_get_type_name (self, ifindex);
}
/**
* nm_platform_link_get_unmanaged:
+ * @self: platform instance
* @ifindex: Interface index.
* @managed: Management status in case %TRUE is returned
*
@@ -662,113 +725,125 @@ nm_platform_link_get_type_name (int ifindex)
* otherwise.
*/
gboolean
-nm_platform_link_get_unmanaged (int ifindex, gboolean *managed)
+nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *managed)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (klass->link_get_unmanaged, FALSE);
- return klass->link_get_unmanaged (platform, ifindex, managed);
+ return klass->link_get_unmanaged (self, ifindex, managed);
}
/**
* nm_platform_link_is_software:
+ * @self: platform instance
* @ifindex: Interface index.
*
* Returns: %TRUE if ifindex belongs to a software interface, not backed by
* a physical device.
*/
gboolean
-nm_platform_link_is_software (int ifindex)
+nm_platform_link_is_software (NMPlatform *self, int ifindex)
{
- return (nm_platform_link_get_type (ifindex) & 0x10000);
+ return (nm_platform_link_get_type (self, ifindex) & 0x10000);
}
/**
* nm_platform_link_supports_slaves:
+ * @self: platform instance
* @ifindex: Interface index.
*
* Returns: %TRUE if ifindex belongs to an interface capable of enslaving
* other interfaces.
*/
gboolean
-nm_platform_link_supports_slaves (int ifindex)
+nm_platform_link_supports_slaves (NMPlatform *self, int ifindex)
{
- return (nm_platform_link_get_type (ifindex) & 0x20000);
+ return (nm_platform_link_get_type (self, ifindex) & 0x20000);
}
/**
* nm_platform_link_refresh:
+ * @self: platform instance
* @ifindex: Interface index
*
* Reload the cache for ifindex synchronously.
*/
gboolean
-nm_platform_link_refresh (int ifindex)
+nm_platform_link_refresh (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
if (klass->link_refresh)
- return klass->link_refresh (platform, ifindex);
+ return klass->link_refresh (self, ifindex);
return TRUE;
}
/**
* nm_platform_link_is_up:
+ * @self: platform instance
* @ifindex: Interface index
*
* Check if the interface is up.
*/
gboolean
-nm_platform_link_is_up (int ifindex)
+nm_platform_link_is_up (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_is_up, FALSE);
- return klass->link_is_up (platform, ifindex);
+ return klass->link_is_up (self, ifindex);
}
/**
* nm_platform_link_is_connected:
+ * @self: platform instance
* @ifindex: Interface index
*
* Check if the interface is connected.
*/
gboolean
-nm_platform_link_is_connected (int ifindex)
+nm_platform_link_is_connected (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_is_connected, FALSE);
- return klass->link_is_connected (platform, ifindex);
+ return klass->link_is_connected (self, ifindex);
}
/**
* nm_platform_link_uses_arp:
+ * @self: platform instance
* @ifindex: Interface index
*
* Check if the interface is configured to use ARP.
*/
gboolean
-nm_platform_link_uses_arp (int ifindex)
+nm_platform_link_uses_arp (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_uses_arp, FALSE);
- return klass->link_uses_arp (platform, ifindex);
+ return klass->link_uses_arp (self, ifindex);
}
/**
* nm_platform_link_get_ipv6_token:
+ * @self: platform instance
* @ifindex: Interface index
* @iid: Tokenized interface identifier
*
@@ -779,21 +854,23 @@ nm_platform_link_uses_arp (int ifindex)
* Returns: %TRUE a tokenized identifier was available
*/
gboolean
-nm_platform_link_get_ipv6_token (int ifindex, NMUtilsIPv6IfaceId *iid)
+nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (iid, FALSE);
if (klass->link_get_ipv6_token)
- return klass->link_get_ipv6_token (platform, ifindex, iid);
+ return klass->link_get_ipv6_token (self, ifindex, iid);
return FALSE;
}
/**
* nm_platform_link_get_user_ip6vll_enabled:
+ * @self: platform instance
* @ifindex: Interface index
*
* Check whether NM handles IPv6LL address creation for the link. If the
@@ -803,20 +880,22 @@ nm_platform_link_get_ipv6_token (int ifindex, NMUtilsIPv6IfaceId *iid)
* Returns: %TRUE if NM handles the IPv6LL address for @ifindex
*/
gboolean
-nm_platform_link_get_user_ipv6ll_enabled (int ifindex)
+nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
if (klass->link_get_user_ipv6ll_enabled)
- return klass->link_get_user_ipv6ll_enabled (platform, ifindex);
+ return klass->link_get_user_ipv6ll_enabled (self, ifindex);
return FALSE;
}
/**
* nm_platform_link_set_user_ip6vll_enabled:
+ * @self: platform instance
* @ifindex: Interface index
*
* Set whether NM handles IPv6LL address creation for the link. If the
@@ -826,50 +905,55 @@ nm_platform_link_get_user_ipv6ll_enabled (int ifindex)
* Returns: %TRUE if the operation was successful, %FALSE if it failed.
*/
gboolean
-nm_platform_link_set_user_ipv6ll_enabled (int ifindex, gboolean enabled)
+nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
if (klass->link_set_user_ipv6ll_enabled)
- return klass->link_set_user_ipv6ll_enabled (platform, ifindex, enabled);
+ return klass->link_set_user_ipv6ll_enabled (self, ifindex, enabled);
return FALSE;
}
/**
* nm_platform_link_set_address:
+ * @self: platform instance
* @ifindex: Interface index
* @address: The new MAC address
*
* Set interface MAC address.
*/
gboolean
-nm_platform_link_set_address (int ifindex, gconstpointer address, size_t length)
+nm_platform_link_set_address (NMPlatform *self, int ifindex, gconstpointer address, size_t length)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (address, FALSE);
g_return_val_if_fail (length > 0, FALSE);
g_return_val_if_fail (klass->link_set_address, FALSE);
- debug ("link: setting '%s' (%d) hardware address", nm_platform_link_get_name (ifindex), ifindex);
- return klass->link_set_address (platform, ifindex, address, length);
+ debug ("link: setting '%s' (%d) hardware address", nm_platform_link_get_name (self, ifindex), ifindex);
+ return klass->link_set_address (self, ifindex, address, length);
}
/**
* nm_platform_link_get_address:
+ * @self: platform instance
* @ifindex: Interface index
* @length: Pointer to a variable to store address length
*
* Saves interface hardware address to @address.
*/
gconstpointer
-nm_platform_link_get_address (int ifindex, size_t *length)
+nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
if (length)
*length = 0;
@@ -877,138 +961,155 @@ nm_platform_link_get_address (int ifindex, size_t *length)
g_return_val_if_fail (ifindex > 0, NULL);
g_return_val_if_fail (klass->link_get_address, NULL);
- return klass->link_get_address (platform, ifindex, length);
+ return klass->link_get_address (self, ifindex, length);
}
gboolean
-nm_platform_link_supports_carrier_detect (int ifindex)
+nm_platform_link_supports_carrier_detect (NMPlatform *self, int ifindex)
{
+ _CHECK_SELF (self, klass, FALSE);
+
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_supports_carrier_detect, FALSE);
- return klass->link_supports_carrier_detect (platform, ifindex);
+ return klass->link_supports_carrier_detect (self, ifindex);
}
gboolean
-nm_platform_link_supports_vlans (int ifindex)
+nm_platform_link_supports_vlans (NMPlatform *self, int ifindex)
{
+ _CHECK_SELF (self, klass, FALSE);
+
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_supports_vlans, FALSE);
- return klass->link_supports_vlans (platform, ifindex);
+ return klass->link_supports_vlans (self, ifindex);
}
/**
* nm_platform_link_set_up:
+ * @self: platform instance
* @ifindex: Interface index
*
* Bring the interface up.
*/
gboolean
-nm_platform_link_set_up (int ifindex)
+nm_platform_link_set_up (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (klass->link_set_up, FALSE);
- debug ("link: setting up '%s' (%d)", nm_platform_link_get_name (ifindex), ifindex);
- return klass->link_set_up (platform, ifindex);
+ debug ("link: setting up '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
+ return klass->link_set_up (self, ifindex);
}
/**
* nm_platform_link_set_down:
+ * @self: platform instance
* @ifindex: Interface index
*
* Take the interface down.
*/
gboolean
-nm_platform_link_set_down (int ifindex)
+nm_platform_link_set_down (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (klass->link_set_down, FALSE);
- debug ("link: setting down '%s' (%d)", nm_platform_link_get_name (ifindex), ifindex);
- return klass->link_set_down (platform, ifindex);
+ debug ("link: setting down '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
+ return klass->link_set_down (self, ifindex);
}
/**
* nm_platform_link_set_arp:
+ * @self: platform instance
* @ifindex: Interface index
*
* Enable ARP on the interface.
*/
gboolean
-nm_platform_link_set_arp (int ifindex)
+nm_platform_link_set_arp (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_set_arp, FALSE);
- debug ("link: setting arp '%s' (%d)", nm_platform_link_get_name (ifindex), ifindex);
- return klass->link_set_arp (platform, ifindex);
+ debug ("link: setting arp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
+ return klass->link_set_arp (self, ifindex);
}
/**
* nm_platform_link_set_noarp:
+ * @self: platform instance
* @ifindex: Interface index
*
* Disable ARP on the interface.
*/
gboolean
-nm_platform_link_set_noarp (int ifindex)
+nm_platform_link_set_noarp (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_set_noarp, FALSE);
- debug ("link: setting noarp '%s' (%d)", nm_platform_link_get_name (ifindex), ifindex);
- return klass->link_set_noarp (platform, ifindex);
+ debug ("link: setting noarp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex);
+ return klass->link_set_noarp (self, ifindex);
}
/**
* nm_platform_link_set_mtu:
+ * @self: platform instance
* @ifindex: Interface index
* @mtu: The new MTU value
*
* Set interface MTU.
*/
gboolean
-nm_platform_link_set_mtu (int ifindex, guint32 mtu)
+nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (mtu > 0, FALSE);
g_return_val_if_fail (klass->link_set_mtu, FALSE);
- debug ("link: setting '%s' (%d) mtu %"G_GUINT32_FORMAT, nm_platform_link_get_name (ifindex), ifindex, mtu);
- return klass->link_set_mtu (platform, ifindex, mtu);
+ debug ("link: setting '%s' (%d) mtu %"G_GUINT32_FORMAT, nm_platform_link_get_name (self, ifindex), ifindex, mtu);
+ return klass->link_set_mtu (self, ifindex, mtu);
}
/**
* nm_platform_link_get_mtu:
+ * @self: platform instance
* @ifindex: Interface index
*
* Returns: MTU value for the interface or 0 on error.
*/
guint32
-nm_platform_link_get_mtu (int ifindex)
+nm_platform_link_get_mtu (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, 0);
g_return_val_if_fail (klass->link_get_mtu, 0);
- return klass->link_get_mtu (platform, ifindex);
+ return klass->link_get_mtu (self, ifindex);
}
/**
* nm_platform_link_get_physical_port_id:
+ * @self: platform instance
* @ifindex: Interface index
*
* The physical port ID, if present, indicates some unique identifier of
@@ -1021,18 +1122,20 @@ nm_platform_link_get_mtu (int ifindex)
* or if the interface has no physical port ID.
*/
char *
-nm_platform_link_get_physical_port_id (int ifindex)
+nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
g_return_val_if_fail (klass->link_get_physical_port_id, NULL);
- return klass->link_get_physical_port_id (platform, ifindex);
+ return klass->link_get_physical_port_id (self, ifindex);
}
/**
* nm_platform_link_get_dev_id:
+ * @self: platform instance
* @ifindex: Interface index
*
* In contrast to the physical device ID (which indicates which parent a
@@ -1043,108 +1146,115 @@ nm_platform_link_get_physical_port_id (int ifindex)
* interface has no device ID.
*/
guint
-nm_platform_link_get_dev_id (int ifindex)
+nm_platform_link_get_dev_id (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, 0);
g_return_val_if_fail (klass->link_get_dev_id, 0);
- return klass->link_get_dev_id (platform, ifindex);
+ return klass->link_get_dev_id (self, ifindex);
}
/**
* nm_platform_link_get_wake_onlan:
+ * @self: platform instance
* @ifindex: Interface index
*
* Returns: the "Wake-on-LAN" status for @ifindex.
*/
gboolean
-nm_platform_link_get_wake_on_lan (int ifindex)
+nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_get_wake_on_lan, FALSE);
- return klass->link_get_wake_on_lan (platform, ifindex);
+ return klass->link_get_wake_on_lan (self, ifindex);
}
/**
* nm_platform_link_enslave:
+ * @self: platform instance
* @master: Interface index of the master
* @slave: Interface index of the slave
*
* Enslave @slave to @master.
*/
gboolean
-nm_platform_link_enslave (int master, int slave)
+nm_platform_link_enslave (NMPlatform *self, int master, int slave)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (master > 0, FALSE);
g_return_val_if_fail (slave> 0, FALSE);
g_return_val_if_fail (klass->link_enslave, FALSE);
debug ("link: enslaving '%s' (%d) to master '%s' (%d)",
- nm_platform_link_get_name (slave), slave,
- nm_platform_link_get_name (master), master);
- return klass->link_enslave (platform, master, slave);
+ nm_platform_link_get_name (self, slave), slave,
+ nm_platform_link_get_name (self, master), master);
+ return klass->link_enslave (self, master, slave);
}
/**
* nm_platform_link_release:
+ * @self: platform instance
* @master: Interface index of the master
* @slave: Interface index of the slave
*
* Release @slave from @master.
*/
gboolean
-nm_platform_link_release (int master, int slave)
+nm_platform_link_release (NMPlatform *self, int master, int slave)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (master > 0, FALSE);
g_return_val_if_fail (slave > 0, FALSE);
g_return_val_if_fail (klass->link_release, FALSE);
- if (nm_platform_link_get_master (slave) != master) {
- platform->error = NM_PLATFORM_ERROR_NOT_SLAVE;
+ if (nm_platform_link_get_master (self, slave) != master) {
+ self->error = NM_PLATFORM_ERROR_NOT_SLAVE;
return FALSE;
}
debug ("link: releasing '%s' (%d) from master '%s' (%d)",
- nm_platform_link_get_name (slave), slave,
- nm_platform_link_get_name (master), master);
- return klass->link_release (platform, master, slave);
+ nm_platform_link_get_name (self, slave), slave,
+ nm_platform_link_get_name (self, master), master);
+ return klass->link_release (self, master, slave);
}
/**
* nm_platform_link_get_master:
+ * @self: platform instance
* @slave: Interface index of the slave.
*
* Returns: Interfase index of the slave's master.
*/
int
-nm_platform_link_get_master (int slave)
+nm_platform_link_get_master (NMPlatform *self, int slave)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (slave >= 0, FALSE);
g_return_val_if_fail (klass->link_get_master, FALSE);
- if (!nm_platform_link_get_name (slave)) {
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ if (!nm_platform_link_get_name (self, slave)) {
+ self->error = NM_PLATFORM_ERROR_NOT_FOUND;
return 0;
}
- return klass->link_get_master (platform, slave);
+ return klass->link_get_master (self, slave);
}
/**
* nm_platform_bridge_add:
+ * @self: platform instance
* @name: New interface name
* @address: (allow-none): set the mac address of the new bridge
* @address_len: the length of the @address
@@ -1152,40 +1262,43 @@ nm_platform_link_get_master (int slave)
* Create a software bridge.
*/
gboolean
-nm_platform_bridge_add (const char *name, const void *address, size_t address_len)
+nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len)
{
debug ("link: adding bridge '%s'", name);
- return nm_platform_link_add (name, NM_LINK_TYPE_BRIDGE, address, address_len);
+ return nm_platform_link_add (self, name, NM_LINK_TYPE_BRIDGE, address, address_len);
}
/**
* nm_platform_bond_add:
+ * @self: platform instance
* @name: New interface name
*
* Create a software bonding device.
*/
gboolean
-nm_platform_bond_add (const char *name)
+nm_platform_bond_add (NMPlatform *self, const char *name)
{
debug ("link: adding bond '%s'", name);
- return nm_platform_link_add (name, NM_LINK_TYPE_BOND, NULL, 0);
+ return nm_platform_link_add (self, name, NM_LINK_TYPE_BOND, NULL, 0);
}
/**
* nm_platform_team_add:
+ * @self: platform instance
* @name: New interface name
*
* Create a software teaming device.
*/
gboolean
-nm_platform_team_add (const char *name)
+nm_platform_team_add (NMPlatform *self, const char *name)
{
debug ("link: adding team '%s'", name);
- return nm_platform_link_add (name, NM_LINK_TYPE_TEAM, NULL, 0);
+ return nm_platform_link_add (self, name, NM_LINK_TYPE_TEAM, NULL, 0);
}
/**
* nm_platform_vlan_add:
+ * @self: platform instance
* @name: New interface name
* @vlanid: VLAN identifier
* @vlanflags: VLAN flags from libnm
@@ -1193,83 +1306,87 @@ nm_platform_team_add (const char *name)
* Create a software VLAN device.
*/
gboolean
-nm_platform_vlan_add (const char *name, int parent, int vlanid, guint32 vlanflags)
+nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (parent >= 0, FALSE);
g_return_val_if_fail (vlanid >= 0, FALSE);
g_return_val_if_fail (name, FALSE);
g_return_val_if_fail (klass->vlan_add, FALSE);
- if (nm_platform_link_exists (name)) {
+ if (nm_platform_link_exists (self, name)) {
debug ("link already exists: %s", name);
- platform->error = NM_PLATFORM_ERROR_EXISTS;
+ self->error = NM_PLATFORM_ERROR_EXISTS;
return FALSE;
}
debug ("link: adding vlan '%s' parent %d vlanid %d vlanflags %x",
name, parent, vlanid, vlanflags);
- return klass->vlan_add (platform, name, parent, vlanid, vlanflags);
+ return klass->vlan_add (self, name, parent, vlanid, vlanflags);
}
gboolean
-nm_platform_master_set_option (int ifindex, const char *option, const char *value)
+nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
g_return_val_if_fail (value, FALSE);
g_return_val_if_fail (klass->master_set_option, FALSE);
- return klass->master_set_option (platform, ifindex, option, value);
+ return klass->master_set_option (self, ifindex, option, value);
}
char *
-nm_platform_master_get_option (int ifindex, const char *option)
+nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
g_return_val_if_fail (klass->master_set_option, FALSE);
- return klass->master_get_option (platform, ifindex, option);
+ return klass->master_get_option (self, ifindex, option);
}
gboolean
-nm_platform_slave_set_option (int ifindex, const char *option, const char *value)
+nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
g_return_val_if_fail (value, FALSE);
g_return_val_if_fail (klass->slave_set_option, FALSE);
- return klass->slave_set_option (platform, ifindex, option, value);
+ return klass->slave_set_option (self, ifindex, option, value);
}
char *
-nm_platform_slave_get_option (int ifindex, const char *option)
+nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
g_return_val_if_fail (klass->slave_set_option, FALSE);
- return klass->slave_get_option (platform, ifindex, option);
+ return klass->slave_get_option (self, ifindex, option);
}
gboolean
-nm_platform_vlan_get_info (int ifindex, int *parent, int *vlanid)
+nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (klass->vlan_get_info, FALSE);
if (parent)
@@ -1277,199 +1394,213 @@ nm_platform_vlan_get_info (int ifindex, int *parent, int *vlanid)
if (vlanid)
*vlanid = 0;
- if (nm_platform_link_get_type (ifindex) != NM_LINK_TYPE_VLAN)
+ if (nm_platform_link_get_type (self, ifindex) != NM_LINK_TYPE_VLAN)
return FALSE;
- return klass->vlan_get_info (platform, ifindex, parent, vlanid);
+ return klass->vlan_get_info (self, ifindex, parent, vlanid);
}
gboolean
-nm_platform_vlan_set_ingress_map (int ifindex, int from, int to)
+nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (klass->vlan_set_ingress_map, FALSE);
debug ("link: setting vlan ingress map for %d from %d to %d", ifindex, from, to);
- return klass->vlan_set_ingress_map (platform, ifindex, from, to);
+ return klass->vlan_set_ingress_map (self, ifindex, from, to);
}
gboolean
-nm_platform_vlan_set_egress_map (int ifindex, int from, int to)
+nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_assert (platform);
g_return_val_if_fail (klass->vlan_set_egress_map, FALSE);
debug ("link: setting vlan egress map for %d from %d to %d", ifindex, from, to);
- return klass->vlan_set_egress_map (platform, ifindex, from, to);
+ return klass->vlan_set_egress_map (self, ifindex, from, to);
}
gboolean
-nm_platform_infiniband_partition_add (int parent, int p_key)
+nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key)
{
const char *parent_name;
char *name;
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (parent >= 0, FALSE);
g_return_val_if_fail (p_key >= 0, FALSE);
g_return_val_if_fail (klass->infiniband_partition_add, FALSE);
- if (nm_platform_link_get_type (parent) != NM_LINK_TYPE_INFINIBAND) {
- platform->error = NM_PLATFORM_ERROR_WRONG_TYPE;
+ if (nm_platform_link_get_type (self, parent) != NM_LINK_TYPE_INFINIBAND) {
+ self->error = NM_PLATFORM_ERROR_WRONG_TYPE;
return FALSE;
}
- parent_name = nm_platform_link_get_name (parent);
+ parent_name = nm_platform_link_get_name (self, parent);
name = g_strdup_printf ("%s.%04x", parent_name, p_key);
- if (nm_platform_link_exists (name)) {
+ if (nm_platform_link_exists (self, name)) {
debug ("infiniband: already exists");
- platform->error = NM_PLATFORM_ERROR_EXISTS;
+ self->error = NM_PLATFORM_ERROR_EXISTS;
g_free (name);
return FALSE;
}
g_free (name);
- return klass->infiniband_partition_add (platform, parent, p_key);
+ return klass->infiniband_partition_add (self, parent, p_key);
}
gboolean
-nm_platform_veth_get_properties (int ifindex, NMPlatformVethProperties *props)
+nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *props)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
- return klass->veth_get_properties (platform, ifindex, props);
+ return klass->veth_get_properties (self, ifindex, props);
}
gboolean
-nm_platform_tun_get_properties (int ifindex, NMPlatformTunProperties *props)
+nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
- return klass->tun_get_properties (platform, ifindex, props);
+ return klass->tun_get_properties (self, ifindex, props);
}
gboolean
-nm_platform_macvlan_get_properties (int ifindex, NMPlatformMacvlanProperties *props)
+nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
- return klass->macvlan_get_properties (platform, ifindex, props);
+ return klass->macvlan_get_properties (self, ifindex, props);
}
gboolean
-nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props)
+nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
- return klass->vxlan_get_properties (platform, ifindex, props);
+ return klass->vxlan_get_properties (self, ifindex, props);
}
gboolean
-nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props)
+nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
- return klass->gre_get_properties (platform, ifindex, props);
+ return klass->gre_get_properties (self, ifindex, props);
}
gboolean
-nm_platform_wifi_get_capabilities (int ifindex, NMDeviceWifiCapabilities *caps)
+nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
- return klass->wifi_get_capabilities (platform, ifindex, caps);
+ return klass->wifi_get_capabilities (self, ifindex, caps);
}
gboolean
-nm_platform_wifi_get_bssid (int ifindex, guint8 *bssid)
+nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
- return klass->wifi_get_bssid (platform, ifindex, bssid);
+ return klass->wifi_get_bssid (self, ifindex, bssid);
}
GByteArray *
-nm_platform_wifi_get_ssid (int ifindex)
+nm_platform_wifi_get_ssid (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, NULL);
- return klass->wifi_get_ssid (platform, ifindex);
+ return klass->wifi_get_ssid (self, ifindex);
}
guint32
-nm_platform_wifi_get_frequency (int ifindex)
+nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
- return klass->wifi_get_frequency (platform, ifindex);
+ return klass->wifi_get_frequency (self, ifindex);
}
int
-nm_platform_wifi_get_quality (int ifindex)
+nm_platform_wifi_get_quality (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
- return klass->wifi_get_quality (platform, ifindex);
+ return klass->wifi_get_quality (self, ifindex);
}
guint32
-nm_platform_wifi_get_rate (int ifindex)
+nm_platform_wifi_get_rate (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
- return klass->wifi_get_rate (platform, ifindex);
+ return klass->wifi_get_rate (self, ifindex);
}
NM80211Mode
-nm_platform_wifi_get_mode (int ifindex)
+nm_platform_wifi_get_mode (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NM_802_11_MODE_UNKNOWN);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, NM_802_11_MODE_UNKNOWN);
- return klass->wifi_get_mode (platform, ifindex);
+ return klass->wifi_get_mode (self, ifindex);
}
void
-nm_platform_wifi_set_mode (int ifindex, NM80211Mode mode)
+nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode)
{
- reset_error ();
+ _CHECK_SELF_VOID (self, klass);
+ reset_error (self);
g_return_if_fail (ifindex > 0);
- klass->wifi_set_mode (platform, ifindex, mode);
+ klass->wifi_set_mode (self, ifindex, mode);
}
static void
@@ -1479,75 +1610,81 @@ wifi_set_powersave (NMPlatform *p, int ifindex, guint32 powersave)
}
void
-nm_platform_wifi_set_powersave (int ifindex, guint32 powersave)
+nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave)
{
- reset_error ();
+ _CHECK_SELF_VOID (self, klass);
+ reset_error (self);
g_return_if_fail (ifindex > 0);
- klass->wifi_set_powersave (platform, ifindex, powersave);
+ klass->wifi_set_powersave (self, ifindex, powersave);
}
guint32
-nm_platform_wifi_find_frequency (int ifindex, const guint32 *freqs)
+nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
g_return_val_if_fail (freqs != NULL, 0);
- return klass->wifi_find_frequency (platform, ifindex, freqs);
+ return klass->wifi_find_frequency (self, ifindex, freqs);
}
void
-nm_platform_wifi_indicate_addressing_running (int ifindex, gboolean running)
+nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running)
{
- reset_error ();
+ _CHECK_SELF_VOID (self, klass);
+ reset_error (self);
g_return_if_fail (ifindex > 0);
- klass->wifi_indicate_addressing_running (platform, ifindex, running);
+ klass->wifi_indicate_addressing_running (self, ifindex, running);
}
guint32
-nm_platform_mesh_get_channel (int ifindex)
+nm_platform_mesh_get_channel (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, 0);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
- return klass->mesh_get_channel (platform, ifindex);
+ return klass->mesh_get_channel (self, ifindex);
}
gboolean
-nm_platform_mesh_set_channel (int ifindex, guint32 channel)
+nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
- return klass->mesh_set_channel (platform, ifindex, channel);
+ return klass->mesh_set_channel (self, ifindex, channel);
}
gboolean
-nm_platform_mesh_set_ssid (int ifindex, const guint8 *ssid, gsize len)
+nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (ssid != NULL, FALSE);
- return klass->mesh_set_ssid (platform, ifindex, ssid, len);
+ return klass->mesh_set_ssid (self, ifindex, ssid, len);
}
#define TO_STRING_DEV_BUF_SIZE (5+15+1)
static const char *
-_to_string_dev (int ifindex, char *buf, size_t size)
+_to_string_dev (NMPlatform *self, int ifindex, char *buf, size_t size)
{
g_assert (buf && size >= TO_STRING_DEV_BUF_SIZE);
if (ifindex) {
- const char *name = ifindex > 0 ? nm_platform_link_get_name (ifindex) : NULL;
+ const char *name = ifindex > 0 && self ? nm_platform_link_get_name (self, ifindex) : NULL;
char *buf2;
strcpy (buf, " dev ");
@@ -1567,29 +1704,32 @@ _to_string_dev (int ifindex, char *buf, size_t size)
/******************************************************************/
GArray *
-nm_platform_ip4_address_get_all (int ifindex)
+nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, NULL);
g_return_val_if_fail (klass->ip4_address_get_all, NULL);
- return klass->ip4_address_get_all (platform, ifindex);
+ return klass->ip4_address_get_all (self, ifindex);
}
GArray *
-nm_platform_ip6_address_get_all (int ifindex)
+nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, NULL);
g_return_val_if_fail (klass->ip6_address_get_all, NULL);
- return klass->ip6_address_get_all (platform, ifindex);
+ return klass->ip6_address_get_all (self, ifindex);
}
gboolean
-nm_platform_ip4_address_add (int ifindex,
+nm_platform_ip4_address_add (NMPlatform *self,
+ int ifindex,
in_addr_t address,
in_addr_t peer_address,
int plen,
@@ -1597,7 +1737,8 @@ nm_platform_ip4_address_add (int ifindex,
guint32 preferred,
const char *label)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -1621,11 +1762,12 @@ nm_platform_ip4_address_add (int ifindex,
debug ("address: adding or updating IPv4 address: %s", nm_platform_ip4_address_to_string (&addr));
}
- return klass->ip4_address_add (platform, ifindex, address, peer_address, plen, lifetime, preferred, label);
+ return klass->ip4_address_add (self, ifindex, address, peer_address, plen, lifetime, preferred, label);
}
gboolean
-nm_platform_ip6_address_add (int ifindex,
+nm_platform_ip6_address_add (NMPlatform *self,
+ int ifindex,
struct in6_addr address,
struct in6_addr peer_address,
int plen,
@@ -1633,7 +1775,8 @@ nm_platform_ip6_address_add (int ifindex,
guint32 preferred,
guint flags)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -1655,16 +1798,17 @@ nm_platform_ip6_address_add (int ifindex,
debug ("address: adding or updating IPv6 address: %s", nm_platform_ip6_address_to_string (&addr));
}
- return klass->ip6_address_add (platform, ifindex, address, peer_address, plen, lifetime, preferred, flags);
+ return klass->ip6_address_add (self, ifindex, address, peer_address, plen, lifetime, preferred, flags);
}
gboolean
-nm_platform_ip4_address_delete (int ifindex, in_addr_t address, int plen, in_addr_t peer_address)
+nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address)
{
char str_dev[TO_STRING_DEV_BUF_SIZE];
char str_peer[NM_UTILS_INET_ADDRSTRLEN];
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -1676,16 +1820,17 @@ nm_platform_ip4_address_delete (int ifindex, in_addr_t address, int plen, in_add
peer_address ? nm_utils_inet4_ntop (peer_address, str_peer) : "",
peer_address ? ", " : "",
ifindex,
- _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
- return klass->ip4_address_delete (platform, ifindex, address, plen, peer_address);
+ _to_string_dev (self, ifindex, str_dev, sizeof (str_dev)));
+ return klass->ip4_address_delete (self, ifindex, address, plen, peer_address);
}
gboolean
-nm_platform_ip6_address_delete (int ifindex, struct in6_addr address, int plen)
+nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen)
{
char str_dev[TO_STRING_DEV_BUF_SIZE];
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -1693,30 +1838,32 @@ nm_platform_ip6_address_delete (int ifindex, struct in6_addr address, int plen)
debug ("address: deleting IPv6 address %s/%d, ifindex %d%s",
nm_utils_inet6_ntop (&address, NULL), plen, ifindex,
- _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
- return klass->ip6_address_delete (platform, ifindex, address, plen);
+ _to_string_dev (self, ifindex, str_dev, sizeof (str_dev)));
+ return klass->ip6_address_delete (self, ifindex, address, plen);
}
gboolean
-nm_platform_ip4_address_exists (int ifindex, in_addr_t address, int plen)
+nm_platform_ip4_address_exists (NMPlatform *self, int ifindex, in_addr_t address, int plen)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (plen > 0, FALSE);
g_return_val_if_fail (klass->ip4_address_exists, FALSE);
- return klass->ip4_address_exists (platform, ifindex, address, plen);
+ return klass->ip4_address_exists (self, ifindex, address, plen);
}
gboolean
-nm_platform_ip6_address_exists (int ifindex, struct in6_addr address, int plen)
+nm_platform_ip6_address_exists (NMPlatform *self, int ifindex, struct in6_addr address, int plen)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
g_return_val_if_fail (plen > 0, FALSE);
g_return_val_if_fail (klass->ip6_address_exists, FALSE);
- return klass->ip6_address_exists (platform, ifindex, address, plen);
+ return klass->ip6_address_exists (self, ifindex, address, plen);
}
static gboolean
@@ -1822,9 +1969,10 @@ _address_get_lifetime (const NMPlatformIPAddress *address, guint32 now, guint32
}
gboolean
-nm_platform_ip4_check_reinstall_device_route (int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric)
+nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric)
{
- g_return_val_if_fail (address, FALSE);
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
if ( ifindex <= 0
|| address->plen <= 0
@@ -1837,11 +1985,12 @@ nm_platform_ip4_check_reinstall_device_route (int ifindex, const NMPlatformIP4Ad
return FALSE;
}
- return klass->ip4_check_reinstall_device_route (platform, ifindex, address, device_route_metric);
+ return klass->ip4_check_reinstall_device_route (self, ifindex, address, device_route_metric);
}
/**
* nm_platform_ip4_address_sync:
+ * @self: platform instance
* @ifindex: Interface index
* @known_addresses: List of addresses
* @device_route_metric: the route metric for adding subnet routes (replaces
@@ -1854,20 +2003,22 @@ nm_platform_ip4_check_reinstall_device_route (int ifindex, const NMPlatformIP4Ad
* Returns: %TRUE on success.
*/
gboolean
-nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint32 device_route_metric)
+nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, guint32 device_route_metric)
{
GArray *addresses;
NMPlatformIP4Address *address;
guint32 now = nm_utils_get_monotonic_timestamp_s ();
int i;
+ _CHECK_SELF (self, klass, FALSE);
+
/* Delete unknown addresses */
- addresses = nm_platform_ip4_address_get_all (ifindex);
+ addresses = nm_platform_ip4_address_get_all (self, ifindex);
for (i = 0; i < addresses->len; i++) {
address = &g_array_index (addresses, NMPlatformIP4Address, i);
if (!array_contains_ip4_address (known_addresses, address))
- nm_platform_ip4_address_delete (ifindex, address->address, address->plen, address->peer_address);
+ nm_platform_ip4_address_delete (self, ifindex, address->address, address->plen, address->peer_address);
}
g_array_free (addresses, TRUE);
@@ -1885,10 +2036,10 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint3
if (!_address_get_lifetime ((NMPlatformIPAddress *) known_address, now, 5, &lifetime, &preferred))
continue;
- if (nm_platform_ip4_check_reinstall_device_route (ifindex, known_address, device_route_metric))
+ if (nm_platform_ip4_check_reinstall_device_route (self, ifindex, known_address, device_route_metric))
reinstall_device_route = TRUE;
- if (!nm_platform_ip4_address_add (ifindex, known_address->address, known_address->peer_address, known_address->plen, lifetime, preferred, known_address->label))
+ if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->peer_address, known_address->plen, lifetime, preferred, known_address->label))
return FALSE;
if (reinstall_device_route) {
@@ -1901,9 +2052,9 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint3
* by the above nm_platform_ip4_check_reinstall_device_route() check.
*/
network = nm_utils_ip4_address_clear_host_address (known_address->address, known_address->plen);
- (void) nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_KERNEL, network, known_address->plen,
+ (void) nm_platform_ip4_route_add (self, ifindex, NM_IP_CONFIG_SOURCE_KERNEL, network, known_address->plen,
0, known_address->address, device_route_metric, 0);
- (void) nm_platform_ip4_route_delete (ifindex, network, known_address->plen,
+ (void) nm_platform_ip4_route_delete (self, ifindex, network, known_address->plen,
NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE);
}
}
@@ -1913,6 +2064,7 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint3
/**
* nm_platform_ip6_address_sync:
+ * @self: platform instance
* @ifindex: Interface index
* @known_addresses: List of addresses
* @keep_link_local: Don't remove link-local address
@@ -1924,7 +2076,7 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint3
* Returns: %TRUE on success.
*/
gboolean
-nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboolean keep_link_local)
+nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, gboolean keep_link_local)
{
GArray *addresses;
NMPlatformIP6Address *address;
@@ -1932,7 +2084,7 @@ nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboole
int i;
/* Delete unknown addresses */
- addresses = nm_platform_ip6_address_get_all (ifindex);
+ addresses = nm_platform_ip6_address_get_all (self, ifindex);
for (i = 0; i < addresses->len; i++) {
address = &g_array_index (addresses, NMPlatformIP6Address, i);
@@ -1941,7 +2093,7 @@ nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboole
continue;
if (!array_contains_ip6_address (known_addresses, address))
- nm_platform_ip6_address_delete (ifindex, address->address, address->plen);
+ nm_platform_ip6_address_delete (self, ifindex, address->address, address->plen);
}
g_array_free (addresses, TRUE);
@@ -1957,7 +2109,7 @@ nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboole
if (!_address_get_lifetime ((NMPlatformIPAddress *) known_address, now, 5, &lifetime, &preferred))
continue;
- if (!nm_platform_ip6_address_add (ifindex, known_address->address,
+ if (!nm_platform_ip6_address_add (self, ifindex, known_address->address,
known_address->peer_address, known_address->plen,
lifetime, preferred, known_address->flags))
return FALSE;
@@ -1967,45 +2119,50 @@ nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboole
}
gboolean
-nm_platform_address_flush (int ifindex)
+nm_platform_address_flush (NMPlatform *self, int ifindex)
{
- return nm_platform_ip4_address_sync (ifindex, NULL, 0)
- && nm_platform_ip6_address_sync (ifindex, NULL, FALSE);
+ _CHECK_SELF (self, klass, FALSE);
+
+ return nm_platform_ip4_address_sync (self, ifindex, NULL, 0)
+ && nm_platform_ip6_address_sync (self, ifindex, NULL, FALSE);
}
/******************************************************************/
GArray *
-nm_platform_ip4_route_get_all (int ifindex, NMPlatformGetRouteMode mode)
+nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
g_return_val_if_fail (klass->ip4_route_get_all, NULL);
- return klass->ip4_route_get_all (platform, ifindex, mode);
+ return klass->ip4_route_get_all (self, ifindex, mode);
}
GArray *
-nm_platform_ip6_route_get_all (int ifindex, NMPlatformGetRouteMode mode)
+nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode)
{
- reset_error ();
+ _CHECK_SELF (self, klass, NULL);
+ reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
g_return_val_if_fail (klass->ip6_route_get_all, NULL);
- return klass->ip6_route_get_all (platform, ifindex, mode);
+ return klass->ip6_route_get_all (self, ifindex, mode);
}
gboolean
-nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source,
+nm_platform_ip4_route_add (NMPlatform *self,
+ int ifindex, NMIPConfigSource source,
in_addr_t network, int plen,
in_addr_t gateway, guint32 pref_src,
guint32 metric, guint32 mss)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_return_val_if_fail (platform, FALSE);
g_return_val_if_fail (0 <= plen && plen <= 32, FALSE);
g_return_val_if_fail (klass->ip4_route_add, FALSE);
@@ -2026,15 +2183,18 @@ nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source,
pref_src ? nm_utils_inet4_ntop (pref_src, pref_src_buf) : "",
pref_src ? ")" : "");
}
- return klass->ip4_route_add (platform, ifindex, source, network, plen, gateway, pref_src, metric, mss);
+ return klass->ip4_route_add (self, ifindex, source, network, plen, gateway, pref_src, metric, mss);
}
gboolean
-nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source,
+nm_platform_ip6_route_add (NMPlatform *self,
+ int ifindex, NMIPConfigSource source,
struct in6_addr network, int plen, struct in6_addr gateway,
guint32 metric, guint32 mss)
{
- g_return_val_if_fail (platform, FALSE);
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
+
g_return_val_if_fail (0 <= plen && plen <= 128, FALSE);
g_return_val_if_fail (klass->ip6_route_add, FALSE);
@@ -2051,61 +2211,61 @@ nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source,
debug ("route: adding or updating IPv6 route: %s", nm_platform_ip6_route_to_string (&route));
}
- return klass->ip6_route_add (platform, ifindex, source, network, plen, gateway, metric, mss);
+ return klass->ip6_route_add (self, ifindex, source, network, plen, gateway, metric, mss);
}
gboolean
-nm_platform_ip4_route_delete (int ifindex, in_addr_t network, int plen, guint32 metric)
+nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric)
{
char str_dev[TO_STRING_DEV_BUF_SIZE];
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_return_val_if_fail (platform, FALSE);
g_return_val_if_fail (klass->ip4_route_delete, FALSE);
debug ("route: deleting IPv4 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s",
nm_utils_inet4_ntop (network, NULL), plen, metric, ifindex,
- _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
- return klass->ip4_route_delete (platform, ifindex, network, plen, metric);
+ _to_string_dev (self, ifindex, str_dev, sizeof (str_dev)));
+ return klass->ip4_route_delete (self, ifindex, network, plen, metric);
}
gboolean
-nm_platform_ip6_route_delete (int ifindex, struct in6_addr network, int plen, guint32 metric)
+nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric)
{
char str_dev[TO_STRING_DEV_BUF_SIZE];
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_return_val_if_fail (platform, FALSE);
g_return_val_if_fail (klass->ip6_route_delete, FALSE);
debug ("route: deleting IPv6 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s",
nm_utils_inet6_ntop (&network, NULL), plen, metric, ifindex,
- _to_string_dev (ifindex, str_dev, sizeof (str_dev)));
- return klass->ip6_route_delete (platform, ifindex, network, plen, metric);
+ _to_string_dev (self, ifindex, str_dev, sizeof (str_dev)));
+ return klass->ip6_route_delete (self, ifindex, network, plen, metric);
}
gboolean
-nm_platform_ip4_route_exists (int ifindex, in_addr_t network, int plen, guint32 metric)
+nm_platform_ip4_route_exists (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_return_val_if_fail (platform, FALSE);
g_return_val_if_fail (klass->ip4_route_exists, FALSE);
- return klass->ip4_route_exists (platform,ifindex, network, plen, metric);
+ return klass->ip4_route_exists (self ,ifindex, network, plen, metric);
}
gboolean
-nm_platform_ip6_route_exists (int ifindex, struct in6_addr network, int plen, guint32 metric)
+nm_platform_ip6_route_exists (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric)
{
- reset_error ();
+ _CHECK_SELF (self, klass, FALSE);
+ reset_error (self);
- g_return_val_if_fail (platform, FALSE);
g_return_val_if_fail (klass->ip6_route_exists, FALSE);
- return klass->ip6_route_exists (platform, ifindex, network, plen, metric);
+ return klass->ip6_route_exists (self, ifindex, network, plen, metric);
}
/******************************************************************/
@@ -2239,7 +2399,7 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address)
str_peer = g_strconcat (" ptp ", s_peer, NULL);
}
- _to_string_dev (address->ifindex, str_dev, sizeof (str_dev));
+ _to_string_dev (NULL, address->ifindex, str_dev, sizeof (str_dev));
if (*address->label)
g_snprintf (str_label, sizeof (str_label), " label %s", address->label);
@@ -2324,7 +2484,7 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address)
str_peer = g_strconcat (" ptp ", s_peer, NULL);
}
- _to_string_dev (address->ifindex, str_dev, sizeof (str_dev));
+ _to_string_dev (NULL, address->ifindex, str_dev, sizeof (str_dev));
nm_platform_addr_flags2str (address->flags, s_flags, sizeof (s_flags));
@@ -2374,7 +2534,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route)
inet_ntop (AF_INET, &route->network, s_network, sizeof(s_network));
inet_ntop (AF_INET, &route->gateway, s_gateway, sizeof(s_gateway));
- _to_string_dev (route->ifindex, str_dev, sizeof (str_dev));
+ _to_string_dev (NULL, route->ifindex, str_dev, sizeof (str_dev));
g_snprintf (to_string_buffer, sizeof (to_string_buffer), "%s/%d via %s%s metric %"G_GUINT32_FORMAT" mss %"G_GUINT32_FORMAT" src %s",
s_network, route->plen, s_gateway,
@@ -2407,7 +2567,7 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route)
inet_ntop (AF_INET6, &route->network, s_network, sizeof(s_network));
inet_ntop (AF_INET6, &route->gateway, s_gateway, sizeof(s_gateway));
- _to_string_dev (route->ifindex, str_dev, sizeof (str_dev));
+ _to_string_dev (NULL, route->ifindex, str_dev, sizeof (str_dev));
g_snprintf (to_string_buffer, sizeof (to_string_buffer), "%s/%d via %s%s metric %"G_GUINT32_FORMAT" mss %"G_GUINT32_FORMAT" src %s",
s_network, route->plen, s_gateway,
@@ -2638,9 +2798,10 @@ log_ip6_route (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, NMPlatform
/******************************************************************/
static gboolean
-_vtr_v4_route_add (int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src)
+_vtr_v4_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src)
{
- return nm_platform_ip4_route_add (ifindex > 0 ? ifindex : route->rx.ifindex,
+ return nm_platform_ip4_route_add (self,
+ ifindex > 0 ? ifindex : route->rx.ifindex,
route->rx.source,
route->r4.network,
route->rx.plen,
@@ -2651,9 +2812,10 @@ _vtr_v4_route_add (int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref
}
static gboolean
-_vtr_v6_route_add (int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src)
+_vtr_v6_route_add (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src)
{
- return nm_platform_ip6_route_add (ifindex > 0 ? ifindex : route->rx.ifindex,
+ return nm_platform_ip6_route_add (self,
+ ifindex > 0 ? ifindex : route->rx.ifindex,
route->rx.source,
route->r6.network,
route->rx.plen,
@@ -2663,18 +2825,20 @@ _vtr_v6_route_add (int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref
}
static gboolean
-_vtr_v4_route_delete (int ifindex, const NMPlatformIPXRoute *route)
+_vtr_v4_route_delete (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route)
{
- return nm_platform_ip4_route_delete (ifindex > 0 ? ifindex : route->rx.ifindex,
+ return nm_platform_ip4_route_delete (self,
+ ifindex > 0 ? ifindex : route->rx.ifindex,
route->r4.network,
route->rx.plen,
route->rx.metric);
}
static gboolean
-_vtr_v6_route_delete (int ifindex, const NMPlatformIPXRoute *route)
+_vtr_v6_route_delete (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route)
{
- return nm_platform_ip6_route_delete (ifindex > 0 ? ifindex : route->rx.ifindex,
+ return nm_platform_ip6_route_delete (self,
+ ifindex > 0 ? ifindex : route->rx.ifindex,
route->r6.network,
route->rx.plen,
route->rx.metric);
@@ -2687,15 +2851,15 @@ _vtr_v4_metric_normalize (guint32 metric)
}
static gboolean
-_vtr_v4_route_delete_default (int ifindex, guint32 metric)
+_vtr_v4_route_delete_default (NMPlatform *self, int ifindex, guint32 metric)
{
- return nm_platform_ip4_route_delete (ifindex, 0, 0, metric);
+ return nm_platform_ip4_route_delete (self, ifindex, 0, 0, metric);
}
static gboolean
-_vtr_v6_route_delete_default (int ifindex, guint32 metric)
+_vtr_v6_route_delete_default (NMPlatform *self, int ifindex, guint32 metric)
{
- return nm_platform_ip6_route_delete (ifindex, in6addr_any, 0, metric);
+ return nm_platform_ip6_route_delete (self, ifindex, in6addr_any, 0, metric);
}
/******************************************************************/
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 920d9cec8c..aee1ee8160 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -39,6 +39,8 @@
/******************************************************************/
+typedef struct _NMPlatform NMPlatform;
+
/* workaround for older libnl version, that does not define these flags. */
#ifndef IFA_F_MANAGETEMPADDR
#define IFA_F_MANAGETEMPADDR 0x100
@@ -252,10 +254,10 @@ typedef struct {
gsize sizeof_route;
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b);
const char *(*route_to_string) (const NMPlatformIPXRoute *route);
- GArray *(*route_get_all) (int ifindex, NMPlatformGetRouteMode mode);
- gboolean (*route_add) (int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src);
- gboolean (*route_delete) (int ifindex, const NMPlatformIPXRoute *route);
- gboolean (*route_delete_default) (int ifindex, guint32 metric);
+ GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
+ gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, guint32 v4_pref_src);
+ gboolean (*route_delete) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
+ gboolean (*route_delete_default) (NMPlatform *self, int ifindex, guint32 metric);
guint32 (*metric_normalize) (guint32 metric);
} NMPlatformVTableRoute;
@@ -346,11 +348,11 @@ typedef struct {
* network configuration daemons stopped. Look at the code first.
*/
-typedef struct {
+struct _NMPlatform {
GObject parent;
NMPlatformError error;
-} NMPlatform;
+};
typedef struct {
GObjectClass parent;
@@ -492,130 +494,132 @@ void nm_platform_setup (GType type);
NMPlatform *nm_platform_get (void);
void nm_platform_free (void);
+#define NM_PLATFORM_GET (nm_platform_get ())
+
/******************************************************************/
-void nm_platform_set_error (NMPlatformError error);
-NMPlatformError nm_platform_get_error (void);
-const char *nm_platform_get_error_msg (void);
-
-void nm_platform_query_devices (void);
-
-gboolean nm_platform_sysctl_set (const char *path, const char *value);
-char *nm_platform_sysctl_get (const char *path);
-gint32 nm_platform_sysctl_get_int32 (const char *path, gint32 fallback);
-gint64 nm_platform_sysctl_get_int_checked (const char *path, guint base, gint64 min, gint64 max, gint64 fallback);
-
-gboolean nm_platform_link_get (int ifindex, NMPlatformLink *link);
-GArray *nm_platform_link_get_all (void);
-gboolean nm_platform_dummy_add (const char *name);
-gboolean nm_platform_bridge_add (const char *name, const void *address, size_t address_len);
-gboolean nm_platform_bond_add (const char *name);
-gboolean nm_platform_team_add (const char *name);
-gboolean nm_platform_link_exists (const char *name);
-gboolean nm_platform_link_delete (int ifindex);
-int nm_platform_link_get_ifindex (const char *name);
-const char *nm_platform_link_get_name (int ifindex);
-NMLinkType nm_platform_link_get_type (int ifindex);
-const char *nm_platform_link_get_type_name (int ifindex);
-gboolean nm_platform_link_get_unmanaged (int ifindex, gboolean *managed);
-gboolean nm_platform_link_is_software (int ifindex);
-gboolean nm_platform_link_supports_slaves (int ifindex);
-
-gboolean nm_platform_link_refresh (int ifindex);
-
-gboolean nm_platform_link_set_up (int ifindex);
-gboolean nm_platform_link_set_down (int ifindex);
-gboolean nm_platform_link_set_arp (int ifindex);
-gboolean nm_platform_link_set_noarp (int ifindex);
-gboolean nm_platform_link_is_up (int ifindex);
-gboolean nm_platform_link_is_connected (int ifindex);
-gboolean nm_platform_link_uses_arp (int ifindex);
-
-gboolean nm_platform_link_get_ipv6_token (int ifindex, NMUtilsIPv6IfaceId *iid);
-
-gboolean nm_platform_link_get_user_ipv6ll_enabled (int ifindex);
-gboolean nm_platform_link_set_user_ipv6ll_enabled (int ifindex, gboolean enabled);
-
-gconstpointer nm_platform_link_get_address (int ifindex, size_t *length);
-gboolean nm_platform_link_set_address (int ifindex, const void *address, size_t length);
-guint32 nm_platform_link_get_mtu (int ifindex);
-gboolean nm_platform_link_set_mtu (int ifindex, guint32 mtu);
-
-char *nm_platform_link_get_physical_port_id (int ifindex);
-guint nm_platform_link_get_dev_id (int ifindex);
-gboolean nm_platform_link_get_wake_on_lan (int ifindex);
-
-gboolean nm_platform_link_supports_carrier_detect (int ifindex);
-gboolean nm_platform_link_supports_vlans (int ifindex);
-
-gboolean nm_platform_link_enslave (int master, int slave);
-gboolean nm_platform_link_release (int master, int slave);
-int nm_platform_link_get_master (int slave);
-gboolean nm_platform_master_set_option (int ifindex, const char *option, const char *value);
-char *nm_platform_master_get_option (int ifindex, const char *option);
-gboolean nm_platform_slave_set_option (int ifindex, const char *option, const char *value);
-char *nm_platform_slave_get_option (int ifindex, const char *option);
-
-gboolean nm_platform_vlan_add (const char *name, int parent, int vlanid, guint32 vlanflags);
-gboolean nm_platform_vlan_get_info (int ifindex, int *parent, int *vlanid);
-gboolean nm_platform_vlan_set_ingress_map (int ifindex, int from, int to);
-gboolean nm_platform_vlan_set_egress_map (int ifindex, int from, int to);
-
-gboolean nm_platform_infiniband_partition_add (int parent, int p_key);
-
-gboolean nm_platform_veth_get_properties (int ifindex, NMPlatformVethProperties *properties);
-gboolean nm_platform_tun_get_properties (int ifindex, NMPlatformTunProperties *properties);
-gboolean nm_platform_macvlan_get_properties (int ifindex, NMPlatformMacvlanProperties *props);
-gboolean nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props);
-gboolean nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props);
-
-gboolean nm_platform_wifi_get_capabilities (int ifindex, NMDeviceWifiCapabilities *caps);
-gboolean nm_platform_wifi_get_bssid (int ifindex, guint8 *bssid);
-GByteArray *nm_platform_wifi_get_ssid (int ifindex);
-guint32 nm_platform_wifi_get_frequency (int ifindex);
-int nm_platform_wifi_get_quality (int ifindex);
-guint32 nm_platform_wifi_get_rate (int ifindex);
-NM80211Mode nm_platform_wifi_get_mode (int ifindex);
-void nm_platform_wifi_set_mode (int ifindex, NM80211Mode mode);
-void nm_platform_wifi_set_powersave (int ifindex, guint32 powersave);
-guint32 nm_platform_wifi_find_frequency (int ifindex, const guint32 *freqs);
-void nm_platform_wifi_indicate_addressing_running (int ifindex, gboolean running);
-
-guint32 nm_platform_mesh_get_channel (int ifindex);
-gboolean nm_platform_mesh_set_channel (int ifindex, guint32 channel);
-gboolean nm_platform_mesh_set_ssid (int ifindex, const guint8 *ssid, gsize len);
-
-GArray *nm_platform_ip4_address_get_all (int ifindex);
-GArray *nm_platform_ip6_address_get_all (int ifindex);
-gboolean nm_platform_ip4_address_add (int ifindex,
+void nm_platform_set_error (NMPlatform *self, NMPlatformError error);
+NMPlatformError nm_platform_get_error (NMPlatform *self);
+const char *nm_platform_get_error_msg (NMPlatform *self);
+
+void nm_platform_query_devices (NMPlatform *self);
+
+gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value);
+char *nm_platform_sysctl_get (NMPlatform *self, const char *path);
+gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback);
+gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint base, gint64 min, gint64 max, gint64 fallback);
+
+gboolean nm_platform_link_get (NMPlatform *self, int ifindex, NMPlatformLink *link);
+GArray *nm_platform_link_get_all (NMPlatform *self);
+gboolean nm_platform_dummy_add (NMPlatform *self, const char *name);
+gboolean nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len);
+gboolean nm_platform_bond_add (NMPlatform *self, const char *name);
+gboolean nm_platform_team_add (NMPlatform *self, const char *name);
+gboolean nm_platform_link_exists (NMPlatform *self, const char *name);
+gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
+int nm_platform_link_get_ifindex (NMPlatform *self, const char *name);
+const char *nm_platform_link_get_name (NMPlatform *self, int ifindex);
+NMLinkType nm_platform_link_get_type (NMPlatform *self, int ifindex);
+const char *nm_platform_link_get_type_name (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *managed);
+gboolean nm_platform_link_is_software (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_supports_slaves (NMPlatform *self, int ifindex);
+
+gboolean nm_platform_link_refresh (NMPlatform *self, int ifindex);
+
+gboolean nm_platform_link_set_up (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_set_down (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_set_arp (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_set_noarp (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_is_up (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_is_connected (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex);
+
+gboolean nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid);
+
+gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
+
+gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length);
+gboolean nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
+guint32 nm_platform_link_get_mtu (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
+
+char *nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex);
+guint nm_platform_link_get_dev_id (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex);
+
+gboolean nm_platform_link_supports_carrier_detect (NMPlatform *self, int ifindex);
+gboolean nm_platform_link_supports_vlans (NMPlatform *self, int ifindex);
+
+gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave);
+gboolean nm_platform_link_release (NMPlatform *self, int master, int slave);
+int nm_platform_link_get_master (NMPlatform *self, int slave);
+gboolean nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
+char *nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option);
+gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
+char *nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option);
+
+gboolean nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags);
+gboolean nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid);
+gboolean nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to);
+gboolean nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to);
+
+gboolean nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key);
+
+gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *properties);
+gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
+gboolean nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props);
+gboolean nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props);
+gboolean nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props);
+
+gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps);
+gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid);
+GByteArray *nm_platform_wifi_get_ssid (NMPlatform *self, int ifindex);
+guint32 nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex);
+int nm_platform_wifi_get_quality (NMPlatform *self, int ifindex);
+guint32 nm_platform_wifi_get_rate (NMPlatform *self, int ifindex);
+NM80211Mode nm_platform_wifi_get_mode (NMPlatform *self, int ifindex);
+void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode);
+void nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave);
+guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs);
+void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running);
+
+guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
+gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
+gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len);
+
+GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
+GArray *nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex);
+gboolean nm_platform_ip4_address_add (NMPlatform *self, int ifindex,
in_addr_t address, in_addr_t peer_address, int plen,
guint32 lifetime, guint32 preferred_lft,
const char *label);
-gboolean nm_platform_ip6_address_add (int ifindex,
+gboolean nm_platform_ip6_address_add (NMPlatform *self, int ifindex,
struct in6_addr address, struct in6_addr peer_address, int plen,
guint32 lifetime, guint32 preferred_lft, guint flags);
-gboolean nm_platform_ip4_address_delete (int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
-gboolean nm_platform_ip6_address_delete (int ifindex, struct in6_addr address, int plen);
-gboolean nm_platform_ip4_address_exists (int ifindex, in_addr_t address, int plen);
-gboolean nm_platform_ip6_address_exists (int ifindex, struct in6_addr address, int plen);
-gboolean nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses, guint32 device_route_metric);
-gboolean nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses, gboolean keep_link_local);
-gboolean nm_platform_address_flush (int ifindex);
-
-gboolean nm_platform_ip4_check_reinstall_device_route (int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
-
-GArray *nm_platform_ip4_route_get_all (int ifindex, NMPlatformGetRouteMode mode);
-GArray *nm_platform_ip6_route_get_all (int ifindex, NMPlatformGetRouteMode mode);
-gboolean nm_platform_ip4_route_add (int ifindex, NMIPConfigSource source,
+gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
+gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
+gboolean nm_platform_ip4_address_exists (NMPlatform *self, int ifindex, in_addr_t address, int plen);
+gboolean nm_platform_ip6_address_exists (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
+gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, guint32 device_route_metric);
+gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, gboolean keep_link_local);
+gboolean nm_platform_address_flush (NMPlatform *self, int ifindex);
+
+gboolean nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
+
+GArray *nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
+GArray *nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
+gboolean nm_platform_ip4_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
in_addr_t network, int plen, in_addr_t gateway,
guint32 pref_src, guint32 metric, guint32 mss);
-gboolean nm_platform_ip6_route_add (int ifindex, NMIPConfigSource source,
+gboolean nm_platform_ip6_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
struct in6_addr network, int plen, struct in6_addr gateway,
guint32 metric, guint32 mss);
-gboolean nm_platform_ip4_route_delete (int ifindex, in_addr_t network, int plen, guint32 metric);
-gboolean nm_platform_ip6_route_delete (int ifindex, struct in6_addr network, int plen, guint32 metric);
-gboolean nm_platform_ip4_route_exists (int ifindex, in_addr_t network, int plen, guint32 metric);
-gboolean nm_platform_ip6_route_exists (int ifindex, struct in6_addr network, int plen, guint32 metric);
+gboolean nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric);
+gboolean nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric);
+gboolean nm_platform_ip4_route_exists (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric);
+gboolean nm_platform_ip6_route_exists (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric);
const char *nm_platform_link_to_string (const NMPlatformLink *link);
const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address);
@@ -630,8 +634,8 @@ int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4R
int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b);
gboolean nm_platform_check_support_libnl_extended_ifa_flags (void);
-gboolean nm_platform_check_support_kernel_extended_ifa_flags (void);
-gboolean nm_platform_check_support_user_ipv6ll (void);
+gboolean nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self);
+gboolean nm_platform_check_support_user_ipv6ll (NMPlatform *self);
void nm_platform_addr_flags2str (int flags, char *buf, size_t size);
diff --git a/src/platform/tests/dump.c b/src/platform/tests/dump.c
index 3bb61da415..e356df0b45 100644
--- a/src/platform/tests/dump.c
+++ b/src/platform/tests/dump.c
@@ -44,21 +44,21 @@ dump_interface (NMPlatformLink *link)
if (link->driver)
printf (" driver: %s\n", link->driver);
printf (" UDI: %s\n", link->udi);
- if (!nm_platform_vlan_get_info (link->ifindex, &vlan_parent, &vlan_id))
+ if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, link->ifindex, &vlan_parent, &vlan_id))
g_assert_not_reached ();
if (vlan_parent)
printf (" vlan parent %d id %d\n", vlan_parent, vlan_id);
- if (nm_platform_link_is_software (link->ifindex))
+ if (nm_platform_link_is_software (NM_PLATFORM_GET, link->ifindex))
printf (" class software\n");
- if (nm_platform_link_supports_slaves (link->ifindex))
+ if (nm_platform_link_supports_slaves (NM_PLATFORM_GET, link->ifindex))
printf (" class supports-slaves\n");
- if (nm_platform_link_supports_carrier_detect (link->ifindex))
+ if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, link->ifindex))
printf (" feature carrier-detect\n");
- if (nm_platform_link_supports_vlans (link->ifindex))
+ if (nm_platform_link_supports_vlans (NM_PLATFORM_GET, link->ifindex))
printf (" feature vlans\n");
- address = nm_platform_link_get_address (link->ifindex, &addrlen);
+ address = nm_platform_link_get_address (NM_PLATFORM_GET, link->ifindex, &addrlen);
if (address) {
printf (" link-address ");
for (i = 0; i < addrlen; i++)
@@ -66,8 +66,8 @@ dump_interface (NMPlatformLink *link)
printf ("\n");
}
- ip4_addresses = nm_platform_ip4_address_get_all (link->ifindex);
- ip6_addresses = nm_platform_ip6_address_get_all (link->ifindex);
+ ip4_addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, link->ifindex);
+ ip6_addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, link->ifindex);
g_assert (ip4_addresses);
g_assert (ip6_addresses);
@@ -85,8 +85,8 @@ dump_interface (NMPlatformLink *link)
g_array_unref (ip4_addresses);
g_array_unref (ip6_addresses);
- ip4_routes = nm_platform_ip4_route_get_all (link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
- ip6_routes = nm_platform_ip6_route_get_all (link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ ip4_routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ ip6_routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
g_assert (ip4_routes);
g_assert (ip6_routes);
@@ -112,7 +112,7 @@ dump_interface (NMPlatformLink *link)
static void
dump_all (void)
{
- GArray *links = nm_platform_link_get_all ();
+ GArray *links = nm_platform_link_get_all (NM_PLATFORM_GET);
int i;
for (i = 0; i < links->len; i++)
diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c
index eea6610d37..07ca8f9108 100644
--- a/src/platform/tests/platform.c
+++ b/src/platform/tests/platform.c
@@ -44,13 +44,13 @@ typedef const char *string_t;
static gboolean
do_sysctl_set (char **argv)
{
- return nm_platform_sysctl_set (argv[0], argv[1]);
+ return nm_platform_sysctl_set (NM_PLATFORM_GET, argv[0], argv[1]);
}
static gboolean
do_sysctl_get (char **argv)
{
- gs_free char *value = nm_platform_sysctl_get (argv[0]);
+ gs_free char *value = nm_platform_sysctl_get (NM_PLATFORM_GET, argv[0]);
printf ("%s\n", value);
@@ -66,7 +66,7 @@ parse_ifindex (const char *str)
ifindex = strtol (str, &endptr, 10);
if (*endptr) {
- ifindex = nm_platform_link_get_ifindex (str);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, str);
}
return ifindex;
@@ -79,7 +79,7 @@ do_link_get_all (char **argv)
NMPlatformLink *device;
int i;
- links = nm_platform_link_get_all ();
+ links = nm_platform_link_get_all (NM_PLATFORM_GET);
for (i = 0; i < links->len; i++) {
device = &g_array_index (links, NMPlatformLink, i);
@@ -93,25 +93,25 @@ do_link_get_all (char **argv)
static gboolean
do_dummy_add (char **argv)
{
- return nm_platform_dummy_add (argv[0]);
+ return nm_platform_dummy_add (NM_PLATFORM_GET, argv[0]);
}
static gboolean
do_bridge_add (char **argv)
{
- return nm_platform_bridge_add (argv[0], NULL, 0);
+ return nm_platform_bridge_add (NM_PLATFORM_GET, argv[0], NULL, 0);
}
static gboolean
do_bond_add (char **argv)
{
- return nm_platform_bond_add (argv[0]);
+ return nm_platform_bond_add (NM_PLATFORM_GET, argv[0]);
}
static gboolean
do_team_add (char **argv)
{
- return nm_platform_team_add (argv[0]);
+ return nm_platform_team_add (NM_PLATFORM_GET, argv[0]);
}
static gboolean
@@ -122,13 +122,13 @@ do_vlan_add (char **argv)
int vlanid = strtol (*argv++, NULL, 10);
guint32 vlan_flags = strtol (*argv++, NULL, 10);
- return nm_platform_vlan_add (name, parent, vlanid, vlan_flags);
+ return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent, vlanid, vlan_flags);
}
static gboolean
do_link_exists (char **argv)
{
- gboolean value = nm_platform_link_exists (argv[0]);
+ gboolean value = nm_platform_link_exists (NM_PLATFORM_GET, argv[0]);
print_boolean (value);
@@ -140,7 +140,7 @@ do_link_exists (char **argv)
do_link_##cmdname (char **argv) \
{ \
int ifindex = parse_ifindex (argv[0]); \
- return ifindex ? nm_platform_link_##cmdname (ifindex) : FALSE; \
+ return ifindex ? nm_platform_link_##cmdname (NM_PLATFORM_GET, ifindex) : FALSE; \
}
#define LINK_CMD_GET_FULL(cmdname, type, cond) \
@@ -149,7 +149,7 @@ do_link_exists (char **argv)
{ \
int ifindex = parse_ifindex (argv[0]); \
if (ifindex) { \
- type##_t value = nm_platform_link_##cmdname (ifindex); \
+ type##_t value = nm_platform_link_##cmdname (NM_PLATFORM_GET, ifindex); \
if (cond) { \
print_##type (value); \
return TRUE; \
@@ -169,7 +169,7 @@ LINK_CMD (delete)
static gboolean
do_link_get_ifindex (char **argv)
{
- int ifindex = nm_platform_link_get_ifindex (argv[0]);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, argv[0]);
if (ifindex)
printf ("%d\n", ifindex);
@@ -213,7 +213,7 @@ do_link_set_address (char **argv)
g_assert (!*endptr);
}
- return nm_platform_link_set_address (ifindex, address, sizeof (address));
+ return nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, address, sizeof (address));
}
static gboolean
@@ -224,7 +224,7 @@ do_link_get_address (char **argv)
size_t length;
int i;
- address = nm_platform_link_get_address (ifindex, &length);
+ address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &length);
if (!address || length <= 0)
return FALSE;
@@ -242,7 +242,7 @@ do_link_set_mtu (char **argv)
int ifindex = parse_ifindex (*argv++);
int mtu = strtoul (*argv++, NULL, 10);
- return nm_platform_link_set_mtu (ifindex, mtu);
+ return nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, mtu);
}
LINK_CMD_GET (get_mtu, decimal);
@@ -255,7 +255,7 @@ do_link_enslave (char **argv)
int master = parse_ifindex (*argv++);
int slave = parse_ifindex (*argv++);
- return nm_platform_link_enslave (master, slave);
+ return nm_platform_link_enslave (NM_PLATFORM_GET, master, slave);
}
static gboolean
@@ -264,7 +264,7 @@ do_link_release (char **argv)
int master = parse_ifindex (*argv++);
int slave = parse_ifindex (*argv++);
- return nm_platform_link_release (master, slave);
+ return nm_platform_link_release (NM_PLATFORM_GET, master, slave);
}
LINK_CMD_GET (get_master, decimal)
@@ -276,7 +276,7 @@ do_master_set_option (char **argv)
const char *option = *argv++;
const char *value = *argv++;
- return nm_platform_master_set_option (ifindex, option, value);
+ return nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option, value);
}
static gboolean
@@ -284,7 +284,7 @@ do_master_get_option (char **argv)
{
int ifindex = parse_ifindex (*argv++);
const char *option = *argv++;
- gs_free char *value = nm_platform_master_get_option (ifindex, option);
+ gs_free char *value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option);
printf ("%s\n", value);
@@ -298,7 +298,7 @@ do_slave_set_option (char **argv)
const char *option = *argv++;
const char *value = *argv++;
- return nm_platform_slave_set_option (ifindex, option, value);
+ return nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option, value);
}
static gboolean
@@ -306,7 +306,7 @@ do_slave_get_option (char **argv)
{
int ifindex = parse_ifindex (*argv++);
const char *option = *argv++;
- gs_free char *value = nm_platform_slave_get_option (ifindex, option);
+ gs_free char *value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, option);
printf ("%s\n", value);
@@ -320,7 +320,7 @@ do_vlan_get_info (char **argv)
int parent;
int vlanid;
- if (!nm_platform_vlan_get_info (ifindex, &parent, &vlanid))
+ if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent, &vlanid))
return FALSE;
printf ("%d %d\n", parent, vlanid);
@@ -335,7 +335,7 @@ do_vlan_set_ingress_map (char **argv)
int from = strtol (*argv++, NULL, 10);
int to = strtol (*argv++, NULL, 10);
- return nm_platform_vlan_set_ingress_map (ifindex, from, to);
+ return nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, from, to);
}
static gboolean
@@ -345,7 +345,7 @@ do_vlan_set_egress_map (char **argv)
int from = strtol (*argv++, NULL, 10);
int to = strtol (*argv++, NULL, 10);
- return nm_platform_vlan_set_egress_map (ifindex, from, to);
+ return nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, from, to);
}
static gboolean
@@ -354,7 +354,7 @@ do_veth_get_properties (char **argv)
int ifindex = parse_ifindex (*argv++);
NMPlatformVethProperties props;
- if (!nm_platform_veth_get_properties (ifindex, &props))
+ if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex, &props))
return FALSE;
printf ("peer: %d\n", props.peer);
@@ -368,7 +368,7 @@ do_tun_get_properties (char **argv)
int ifindex = parse_ifindex (*argv++);
NMPlatformTunProperties props;
- if (!nm_platform_tun_get_properties (ifindex, &props))
+ if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, ifindex, &props))
return FALSE;
printf ("mode: %s\n", props.mode);
@@ -396,7 +396,7 @@ do_macvlan_get_properties (char **argv)
int ifindex = parse_ifindex (*argv++);
NMPlatformMacvlanProperties props;
- if (!nm_platform_macvlan_get_properties (ifindex, &props))
+ if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, ifindex, &props))
return FALSE;
printf ("parent: %d\n", props.parent_ifindex);
@@ -413,7 +413,7 @@ do_vxlan_get_properties (char **argv)
NMPlatformVxlanProperties props;
char addrstr[INET6_ADDRSTRLEN];
- if (!nm_platform_vxlan_get_properties (ifindex, &props))
+ if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, ifindex, &props))
return FALSE;
printf ("parent-ifindex: %u\n", props.parent_ifindex);
@@ -460,7 +460,7 @@ do_gre_get_properties (char **argv)
NMPlatformGreProperties props;
char addrstr[INET_ADDRSTRLEN];
- if (!nm_platform_gre_get_properties (ifindex, &props))
+ if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, ifindex, &props))
return FALSE;
printf ("parent-ifindex: %u\n", props.parent_ifindex);
@@ -496,7 +496,7 @@ do_ip4_address_get_all (char **argv)
int i;
if (ifindex) {
- addresses = nm_platform_ip4_address_get_all (ifindex);
+ addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
for (i = 0; i < addresses->len; i++) {
address = &g_array_index (addresses, NMPlatformIP4Address, i);
inet_ntop (AF_INET, &address->address, addrstr, sizeof (addrstr));
@@ -518,7 +518,7 @@ do_ip6_address_get_all (char **argv)
int i;
if (ifindex) {
- addresses = nm_platform_ip6_address_get_all (ifindex);
+ addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
for (i = 0; i < addresses->len; i++) {
address = &g_array_index (addresses, NMPlatformIP6Address, i);
inet_ntop (AF_INET6, &address->address, addrstr, sizeof (addrstr));
@@ -576,7 +576,7 @@ do_ip4_address_add (char **argv)
guint32 lifetime = strtol (*argv++, NULL, 10);
guint32 preferred = strtol (*argv++, NULL, 10);
- gboolean value = nm_platform_ip4_address_add (ifindex, address, 0, plen, lifetime, preferred, NULL);
+ gboolean value = nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, address, 0, plen, lifetime, preferred, NULL);
return value;
} else
return FALSE;
@@ -594,7 +594,7 @@ do_ip6_address_add (char **argv)
guint32 preferred = strtol (*argv++, NULL, 10);
guint flags = (*argv) ? rtnl_addr_str2flags (*argv++) : 0;
- gboolean value = nm_platform_ip6_address_add (ifindex, address, in6addr_any, plen, lifetime, preferred, flags);
+ gboolean value = nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, address, in6addr_any, plen, lifetime, preferred, flags);
return value;
} else
return FALSE;
@@ -608,7 +608,7 @@ do_ip6_address_add (char **argv)
v##_t address; \
int plen; \
if (ifindex && parse_##v##_address (*argv++, &address, &plen)) { \
- gboolean value = nm_platform_##v##_address_##cmdname (ifindex, address, plen, ##__VA_ARGS__); \
+ gboolean value = nm_platform_##v##_address_##cmdname (NM_PLATFORM_GET, ifindex, address, plen, ##__VA_ARGS__); \
if (print) { \
print_boolean (value); \
return TRUE; \
@@ -633,7 +633,7 @@ do_ip4_route_get_all (char **argv)
int i;
if (ifindex) {
- routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
for (i = 0; i < routes->len; i++) {
route = &g_array_index (routes, NMPlatformIP4Route, i);
inet_ntop (AF_INET, &route->network, networkstr, sizeof (networkstr));
@@ -657,7 +657,7 @@ do_ip6_route_get_all (char **argv)
int i;
if (ifindex) {
- routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
for (i = 0; i < routes->len; i++) {
route = &g_array_index (routes, NMPlatformIP6Route, i);
inet_ntop (AF_INET6, &route->network, networkstr, sizeof (networkstr));
@@ -683,7 +683,7 @@ do_ip4_route_add (char **argv)
metric = strtol (*argv++, NULL, 10);
mss = strtol (*argv++, NULL, 10);
- return nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER,
+ return nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER,
network, plen, gateway, 0,
metric, mss);
}
@@ -699,7 +699,7 @@ do_ip6_route_add (char **argv)
parse_ip6_address (*argv++, &gateway, NULL);
metric = strtol (*argv++, NULL, 10);
mss = strtol (*argv++, NULL, 10);
- return nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER,
+ return nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER,
network, plen, gateway,
metric, mss);
}
@@ -714,7 +714,7 @@ do_ip4_route_delete (char **argv)
parse_ip4_address (*argv++, &network, &plen);
metric = strtol (*argv++, NULL, 10);
- return nm_platform_ip4_route_delete (ifindex, network, plen, metric);
+ return nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric);
}
static gboolean
@@ -727,7 +727,7 @@ do_ip6_route_delete (char **argv)
parse_ip6_address (*argv++, &network, &plen);
metric = strtol (*argv++, NULL, 10);
- return nm_platform_ip6_route_delete (ifindex, network, plen, metric);
+ return nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric);
}
static gboolean
@@ -740,7 +740,7 @@ do_ip4_route_exists (char **argv)
parse_ip4_address (*argv++, &network, &plen);
metric = strtol (*argv++, NULL, 10);
- print_boolean (nm_platform_ip4_route_exists (ifindex, network, plen, metric));
+ print_boolean (nm_platform_ip4_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
return TRUE;
}
@@ -754,7 +754,7 @@ do_ip6_route_exists (char **argv)
parse_ip6_address (*argv++, &network, &plen);
metric = strtol (*argv++, NULL, 10);
- print_boolean (nm_platform_ip6_route_exists (ifindex, network, plen, metric));
+ print_boolean (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
return TRUE;
}
@@ -892,9 +892,9 @@ main (int argc, char **argv)
error ("\n");
}
- error = nm_platform_get_error ();
+ error = nm_platform_get_error (NM_PLATFORM_GET);
if (error) {
- const char *msg = nm_platform_get_error_msg ();
+ const char *msg = nm_platform_get_error_msg (NM_PLATFORM_GET);
error ("nm-platform: %s\n", msg);
}
diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c
index 21cd427fed..9463ae4e9f 100644
--- a/src/platform/tests/test-address.c
+++ b/src/platform/tests/test-address.c
@@ -55,7 +55,7 @@ ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *r
static void
test_ip4_address (void)
{
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback, ifindex);
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_address_callback, ifindex);
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback, ifindex);
@@ -68,21 +68,21 @@ test_ip4_address (void)
inet_pton (AF_INET, IP4_ADDRESS, &addr);
/* Add address */
- g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
no_error ();
- g_assert (nm_platform_ip4_address_add (ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
no_error ();
- g_assert (nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
no_error ();
accept_signal (address_added);
/* Add address again (aka update) */
- g_assert (nm_platform_ip4_address_add (ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
no_error ();
accept_signal (address_changed);
/* Test address listing */
- addresses = nm_platform_ip4_address_get_all (ifindex);
+ addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
g_assert (addresses);
no_error ();
g_assert_cmpint (addresses->len, ==, 1);
@@ -93,13 +93,13 @@ test_ip4_address (void)
g_array_unref (addresses);
/* Remove address */
- g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
+ g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0));
no_error ();
- g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_removed);
/* Remove address again */
- g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
+ g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0));
no_error ();
free_signal (address_added);
@@ -110,7 +110,7 @@ test_ip4_address (void)
static void
test_ip6_address (void)
{
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback, ifindex);
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_address_callback, ifindex);
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback, ifindex);
@@ -124,21 +124,21 @@ test_ip6_address (void)
inet_pton (AF_INET6, IP6_ADDRESS, &addr);
/* Add address */
- g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
no_error ();
- g_assert (nm_platform_ip6_address_add (ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
no_error ();
- g_assert (nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
no_error ();
accept_signal (address_added);
/* Add address again (aka update) */
- g_assert (nm_platform_ip6_address_add (ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
no_error ();
accept_signal (address_changed);
/* Test address listing */
- addresses = nm_platform_ip6_address_get_all (ifindex);
+ addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
g_assert (addresses);
no_error ();
g_assert_cmpint (addresses->len, ==, 1);
@@ -149,13 +149,13 @@ test_ip6_address (void)
g_array_unref (addresses);
/* Remove address */
- g_assert (nm_platform_ip6_address_delete (ifindex, addr, IP6_PLEN));
+ g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
no_error ();
- g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
accept_signal (address_removed);
/* Remove address again */
- g_assert (nm_platform_ip6_address_delete (ifindex, addr, IP6_PLEN));
+ g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
no_error ();
free_signal (address_added);
@@ -168,7 +168,7 @@ test_ip4_address_external (void)
{
SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback);
SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback);
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
in_addr_t addr;
guint32 lifetime = 2000;
guint32 preferred = 1000;
@@ -179,28 +179,28 @@ test_ip4_address_external (void)
/* Looks like addresses are not announced by kerenl when the interface
* is down. Link-local IPv6 address is automatically added.
*/
- g_assert (nm_platform_link_set_up (nm_platform_link_get_ifindex (DEVICE_NAME)));
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
/* Add/delete notification */
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred);
wait_signal (address_added);
- g_assert (nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME);
wait_signal (address_removed);
- g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
/* Add/delete conflict */
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred);
- g_assert (nm_platform_ip4_address_add (ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
no_error ();
- g_assert (nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_added);
/*run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME);
g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
no_error ();
- g_assert (!nm_platform_ip4_address_exists (ifindex, addr, IP4_PLEN));
+ g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_removed);*/
free_signal (address_added);
@@ -212,7 +212,7 @@ test_ip6_address_external (void)
{
SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback);
SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback);
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
struct in6_addr addr;
guint32 lifetime = 2000;
guint32 preferred = 1000;
@@ -224,22 +224,22 @@ test_ip6_address_external (void)
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred);
wait_signal (address_added);
- g_assert (nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME);
wait_signal (address_removed);
- g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
/* Add/delete conflict */
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred);
- g_assert (nm_platform_ip6_address_add (ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
no_error ();
- g_assert (nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
accept_signal (address_added);
/*run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME);
- g_assert (nm_platform_ip6_address_delete (ifindex, addr, IP6_PLEN));
+ g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
no_error ();
- g_assert (!nm_platform_ip6_address_exists (ifindex, addr, IP6_PLEN));
+ g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
wait_signal (address_removed);*/
free_signal (address_added);
@@ -257,9 +257,9 @@ setup_tests (void)
{
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
- nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
- g_assert (!nm_platform_link_exists (DEVICE_NAME));
- g_assert (nm_platform_dummy_add (DEVICE_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
+ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
wait_signal (link_added);
free_signal (link_added);
diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c
index 796ca874e5..29892c9c83 100644
--- a/src/platform/tests/test-cleanup.c
+++ b/src/platform/tests/test-cleanup.c
@@ -35,27 +35,27 @@ test_cleanup_internal (void)
inet_pton (AF_INET6, "2001:db8:e:f:1:2:3:4", &gateway6);
/* Create and set up device */
- g_assert (nm_platform_dummy_add (DEVICE_NAME));
+ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
wait_signal (link_added);
free_signal (link_added);
- g_assert (nm_platform_link_set_up (nm_platform_link_get_ifindex (DEVICE_NAME)));
- ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
g_assert (ifindex > 0);
/* Add routes and addresses */
- g_assert (nm_platform_ip4_address_add (ifindex, addr4, 0, plen4, lifetime, preferred, NULL));
- g_assert (nm_platform_ip6_address_add (ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags));
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss));
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss));
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss));
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss));
-
- addresses4 = nm_platform_ip4_address_get_all (ifindex);
- addresses6 = nm_platform_ip6_address_get_all (ifindex);
- routes4 = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
- routes6 = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, 0, plen4, lifetime, preferred, NULL));
+ g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss));
+
+ addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
+ addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
+ routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
g_assert_cmpint (addresses4->len, ==, 1);
g_assert_cmpint (addresses6->len, ==, 1);
@@ -68,12 +68,12 @@ test_cleanup_internal (void)
g_array_unref (routes6);
/* Delete interface with all addresses and routes */
- g_assert (nm_platform_link_delete (ifindex));
+ g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
- addresses4 = nm_platform_ip4_address_get_all (ifindex);
- addresses6 = nm_platform_ip6_address_get_all (ifindex);
- routes4 = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
- routes6 = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
+ addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
+ routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
g_assert_cmpint (addresses4->len, ==, 0);
g_assert_cmpint (addresses6->len, ==, 0);
@@ -95,8 +95,8 @@ init_tests (int *argc, char ***argv)
void
setup_tests (void)
{
- nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
- g_assert (!nm_platform_link_exists (DEVICE_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
g_test_add_func ("/internal", test_cleanup_internal);
/* FIXME: add external cleanup check */
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index 1980282dc8..708e2cad82 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -84,7 +84,7 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
if (data->ifindex && data->ifindex != received->ifindex)
return;
- if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (ifindex)) != 0)
+ if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (NM_PLATFORM_GET, ifindex)) != 0)
return;
if (change_type != data->change_type)
return;
@@ -101,13 +101,13 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
data->received = TRUE;
if (change_type == NM_PLATFORM_SIGNAL_REMOVED)
- g_assert (!nm_platform_link_get_name (ifindex));
+ g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
else
- g_assert (nm_platform_link_get_name (ifindex));
+ g_assert (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
/* Check the data */
g_assert (received->ifindex > 0);
- links = nm_platform_link_get_all ();
+ links = nm_platform_link_get_all (NM_PLATFORM_GET);
for (i = 0; i < links->len; i++) {
cached = &g_array_index (links, NMPlatformLink, i);
if (cached->ifindex == received->ifindex) {
@@ -221,9 +221,9 @@ _assert_ip4_route_exists (const char *file, guint line, const char *func, gboole
exists ? "doesn't" : "does");
}
- ifindex = nm_platform_link_get_ifindex (ifname);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname);
g_assert (ifindex > 0);
- if (!nm_platform_ip4_route_exists (ifindex, network, plen, metric) != !exists) {
+ if (!nm_platform_ip4_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric) != !exists) {
g_error ("[%s:%u] %s(): The ip4 route %s/%d metric %u %s, but platform thinks %s",
file, line, func,
nm_utils_inet4_ntop (network, NULL), plen, metric,
@@ -278,7 +278,7 @@ main (int argc, char **argv)
result = g_test_run ();
- nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
nm_platform_free ();
return result;
diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h
index 367833d111..e51f26ab2f 100644
--- a/src/platform/tests/test-common.h
+++ b/src/platform/tests/test-common.h
@@ -15,7 +15,7 @@
#define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__)
-#define error(err) g_assert (nm_platform_get_error () == err)
+#define error(err) g_assert (nm_platform_get_error (NM_PLATFORM_GET) == err)
#define no_error() error (NM_PLATFORM_ERROR_NONE)
typedef struct {
diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
index 323ebc921c..dcce8827f2 100644
--- a/src/platform/tests/test-link.c
+++ b/src/platform/tests/test-link.c
@@ -21,68 +21,68 @@ test_bogus(void)
{
size_t addrlen;
- g_assert (!nm_platform_link_exists (BOGUS_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, BOGUS_NAME));
no_error ();
- g_assert (!nm_platform_link_delete (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_ifindex (BOGUS_NAME));
+ g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, BOGUS_NAME));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_name (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_type (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_type_name (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_get_type_name (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_set_up (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_set_up (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_set_down (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_set_down (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_set_arp (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_set_arp (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_set_noarp (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_set_noarp (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_is_up (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_is_connected (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_uses_arp (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_address (BOGUS_IFINDEX, &addrlen));
+ g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, &addrlen));
g_assert (!addrlen);
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_address (BOGUS_IFINDEX, NULL));
+ g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_set_mtu (BOGUS_IFINDEX, MTU));
+ g_assert (!nm_platform_link_set_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX, MTU));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_mtu (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_get_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_supports_carrier_detect (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_supports_vlans (BOGUS_IFINDEX));
+ g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, BOGUS_IFINDEX));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_vlan_get_info (BOGUS_IFINDEX, NULL, NULL));
+ g_assert (!nm_platform_vlan_get_info (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL, NULL));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_vlan_set_ingress_map (BOGUS_IFINDEX, 0, 0));
+ g_assert (!nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_vlan_set_egress_map (BOGUS_IFINDEX, 0, 0));
+ g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
error (NM_PLATFORM_ERROR_NOT_FOUND);
}
static void
test_loopback (void)
{
- g_assert (nm_platform_link_exists (LO_NAME));
- g_assert_cmpint (nm_platform_link_get_type (LO_INDEX), ==, NM_LINK_TYPE_LOOPBACK);
- g_assert_cmpint (nm_platform_link_get_ifindex (LO_NAME), ==, LO_INDEX);
- g_assert_cmpstr (nm_platform_link_get_name (LO_INDEX), ==, LO_NAME);
- g_assert_cmpstr (nm_platform_link_get_type_name (LO_INDEX), ==, LO_TYPEDESC);
-
- g_assert (nm_platform_link_supports_carrier_detect (LO_INDEX));
- g_assert (!nm_platform_link_supports_vlans (LO_INDEX));
+ g_assert (nm_platform_link_exists (NM_PLATFORM_GET, LO_NAME));
+ g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, LO_INDEX), ==, NM_LINK_TYPE_LOOPBACK);
+ g_assert_cmpint (nm_platform_link_get_ifindex (NM_PLATFORM_GET, LO_NAME), ==, LO_INDEX);
+ g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, LO_INDEX), ==, LO_NAME);
+ g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, LO_INDEX), ==, LO_TYPEDESC);
+
+ g_assert (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, LO_INDEX));
+ g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, LO_INDEX));
}
static int
@@ -90,43 +90,43 @@ software_add (NMLinkType link_type, const char *name)
{
switch (link_type) {
case NM_LINK_TYPE_DUMMY:
- return nm_platform_dummy_add (name);
+ return nm_platform_dummy_add (NM_PLATFORM_GET, name);
case NM_LINK_TYPE_BRIDGE:
- return nm_platform_bridge_add (name, NULL, 0);
+ return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0);
case NM_LINK_TYPE_BOND:
{
- gboolean bond0_exists = nm_platform_link_exists ("bond0");
- gboolean result = nm_platform_bond_add (name);
- NMPlatformError error = nm_platform_get_error ();
+ gboolean bond0_exists = nm_platform_link_exists (NM_PLATFORM_GET, "bond0");
+ gboolean result = nm_platform_bond_add (NM_PLATFORM_GET, name);
+ NMPlatformError error = nm_platform_get_error (NM_PLATFORM_GET);
/* Check that bond0 is *not* automatically created. */
if (!bond0_exists)
- g_assert (!nm_platform_link_exists ("bond0"));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "bond0"));
- nm_platform_set_error (error);
+ nm_platform_set_error (NM_PLATFORM_GET, error);
return result;
}
case NM_LINK_TYPE_TEAM:
- return nm_platform_team_add (name);
+ return nm_platform_team_add (NM_PLATFORM_GET, name);
case NM_LINK_TYPE_VLAN: {
SignalData *parent_added;
SignalData *parent_changed;
/* Don't call link_callback for the bridge interface */
parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME);
- if (nm_platform_bridge_add (PARENT_NAME, NULL, 0))
+ if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0))
wait_signal (parent_added);
free_signal (parent_added);
{
- int parent_ifindex = nm_platform_link_get_ifindex (PARENT_NAME);
+ int parent_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME);
parent_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, parent_ifindex);
- g_assert (nm_platform_link_set_up (parent_ifindex));
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, parent_ifindex));
accept_signal (parent_changed);
free_signal (parent_changed);
- return nm_platform_vlan_add (name, parent_ifindex, VLAN_ID, 0);
+ return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0);
}
}
default:
@@ -144,7 +144,7 @@ test_slave (int master, int type, SignalData *master_changed)
char *value;
g_assert (software_add (type, SLAVE_NAME));
- ifindex = nm_platform_link_get_ifindex (SLAVE_NAME);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, SLAVE_NAME);
g_assert (ifindex > 0);
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
@@ -154,19 +154,19 @@ test_slave (int master, int type, SignalData *master_changed)
*
* See https://bugzilla.redhat.com/show_bug.cgi?id=910348
*/
- g_assert (nm_platform_link_set_down (ifindex));
- g_assert (!nm_platform_link_is_up (ifindex));
+ g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
/* Enslave */
link_changed->ifindex = ifindex;
- g_assert (nm_platform_link_enslave (master, ifindex)); no_error ();
- g_assert_cmpint (nm_platform_link_get_master (ifindex), ==, master); no_error ();
+ g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error ();
+ g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, master); no_error ();
accept_signal (link_changed);
accept_signal (master_changed);
/* Set master up */
- g_assert (nm_platform_link_set_up (master));
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, master));
accept_signal (master_changed);
/* Master with a disconnected slave is disconnected
@@ -174,26 +174,26 @@ test_slave (int master, int type, SignalData *master_changed)
* For some reason, bonding and teaming slaves are automatically set up. We
* need to set them back down for this test.
*/
- switch (nm_platform_link_get_type (master)) {
+ switch (nm_platform_link_get_type (NM_PLATFORM_GET, master)) {
case NM_LINK_TYPE_BOND:
case NM_LINK_TYPE_TEAM:
- g_assert (nm_platform_link_set_down (ifindex));
+ g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
accept_signal (master_changed);
break;
default:
break;
}
- g_assert (!nm_platform_link_is_up (ifindex));
- g_assert (!nm_platform_link_is_connected (ifindex));
- if (nm_platform_link_is_connected (master)) {
- if (nm_platform_link_get_type (master) == NM_LINK_TYPE_TEAM) {
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
+ if (nm_platform_link_is_connected (NM_PLATFORM_GET, master)) {
+ if (nm_platform_link_get_type (NM_PLATFORM_GET, master) == NM_LINK_TYPE_TEAM) {
/* Older team versions (e.g. Fedora 17) have a bug that team master stays
* IFF_LOWER_UP even if its slave is down. Double check it with iproute2 and if
* `ip link` also claims master to be up, accept it. */
char *stdout_str = NULL;
- nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (master));
+ nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (NM_PLATFORM_GET, master));
g_assert (strstr (stdout_str, "LOWER_UP"));
g_free (stdout_str);
@@ -202,9 +202,9 @@ test_slave (int master, int type, SignalData *master_changed)
}
/* Set slave up and see if master gets up too */
- g_assert (nm_platform_link_set_up (ifindex)); no_error ();
- g_assert (nm_platform_link_is_connected (ifindex));
- g_assert (nm_platform_link_is_connected (master));
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, master));
accept_signal (link_changed);
accept_signal (master_changed);
@@ -212,16 +212,16 @@ test_slave (int master, int type, SignalData *master_changed)
*
* Gracefully succeed if already enslaved.
*/
- g_assert (nm_platform_link_enslave (master, ifindex)); no_error ();
+ g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error ();
accept_signal (link_changed);
accept_signal (master_changed);
/* Set slave option */
switch (type) {
case NM_LINK_TYPE_BRIDGE:
- g_assert (nm_platform_slave_set_option (ifindex, "priority", "789"));
+ g_assert (nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789"));
no_error ();
- value = nm_platform_slave_get_option (ifindex, "priority");
+ value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, "priority");
no_error ();
g_assert_cmpstr (value, ==, "789");
g_free (value);
@@ -231,17 +231,17 @@ test_slave (int master, int type, SignalData *master_changed)
}
/* Release */
- g_assert (nm_platform_link_release (master, ifindex));
- g_assert_cmpint (nm_platform_link_get_master (ifindex), ==, 0); no_error ();
+ g_assert (nm_platform_link_release (NM_PLATFORM_GET, master, ifindex));
+ g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); no_error ();
accept_signal (link_changed);
accept_signal (master_changed);
/* Release again */
- g_assert (!nm_platform_link_release (master, ifindex));
+ g_assert (!nm_platform_link_release (NM_PLATFORM_GET, master, ifindex));
error (NM_PLATFORM_ERROR_NOT_SLAVE);
/* Remove */
- g_assert (nm_platform_link_delete (ifindex));
+ g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
no_error ();
accept_signal (link_removed);
@@ -264,16 +264,16 @@ test_software (NMLinkType link_type, const char *link_typename)
g_assert (software_add (link_type, DEVICE_NAME));
no_error ();
wait_signal (link_added);
- g_assert (nm_platform_link_exists (DEVICE_NAME));
- ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
g_assert (ifindex >= 0);
- g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, link_type);
- g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, link_typename);
+ g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, link_type);
+ g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, link_typename);
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
if (link_type == NM_LINK_TYPE_VLAN) {
- g_assert (nm_platform_vlan_get_info (ifindex, &vlan_parent, &vlan_id));
- g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (PARENT_NAME));
+ g_assert (nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &vlan_parent, &vlan_id));
+ g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME));
g_assert_cmpint (vlan_id, ==, VLAN_ID);
no_error ();
}
@@ -283,28 +283,28 @@ test_software (NMLinkType link_type, const char *link_typename)
error (NM_PLATFORM_ERROR_EXISTS);
/* Set ARP/NOARP */
- g_assert (nm_platform_link_uses_arp (ifindex));
- g_assert (nm_platform_link_set_noarp (ifindex));
- g_assert (!nm_platform_link_uses_arp (ifindex));
+ g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_set_noarp (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
- g_assert (nm_platform_link_set_arp (ifindex));
- g_assert (nm_platform_link_uses_arp (ifindex));
+ g_assert (nm_platform_link_set_arp (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
/* Set master option */
switch (link_type) {
case NM_LINK_TYPE_BRIDGE:
- g_assert (nm_platform_master_set_option (ifindex, "forward_delay", "789"));
+ g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789"));
no_error ();
- value = nm_platform_master_get_option (ifindex, "forward_delay");
+ value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay");
no_error ();
g_assert_cmpstr (value, ==, "789");
g_free (value);
break;
case NM_LINK_TYPE_BOND:
- g_assert (nm_platform_master_set_option (ifindex, "mode", "active-backup"));
+ g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup"));
no_error ();
- value = nm_platform_master_get_option (ifindex, "mode");
+ value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "mode");
no_error ();
/* When reading back, the output looks slightly different. */
g_assert (g_str_has_prefix (value, "active-backup"));
@@ -328,24 +328,24 @@ test_software (NMLinkType link_type, const char *link_typename)
}
/* Delete */
- g_assert (nm_platform_link_delete (ifindex));
+ g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
no_error ();
- g_assert (!nm_platform_link_exists (DEVICE_NAME)); no_error ();
- g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_NONE);
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error ();
+ g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_NONE);
error (NM_PLATFORM_ERROR_NOT_FOUND);
- g_assert (!nm_platform_link_get_type (ifindex));
+ g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, ifindex));
error (NM_PLATFORM_ERROR_NOT_FOUND);
accept_signal (link_removed);
/* Delete again */
- g_assert (!nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME)));
+ g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
error (NM_PLATFORM_ERROR_NOT_FOUND);
/* VLAN: Delete parent */
if (link_type == NM_LINK_TYPE_VLAN) {
SignalData *link_removed_parent = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, vlan_parent);
- g_assert (nm_platform_link_delete (vlan_parent));
+ g_assert (nm_platform_link_delete (NM_PLATFORM_GET, vlan_parent));
accept_signal (link_removed_parent);
free_signal (link_removed_parent);
}
@@ -400,75 +400,75 @@ test_internal (void)
int ifindex;
/* Check the functions for non-existent devices */
- g_assert (!nm_platform_link_exists (DEVICE_NAME)); no_error ();
- g_assert (!nm_platform_link_get_ifindex (DEVICE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error ();
+ g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
error (NM_PLATFORM_ERROR_NOT_FOUND);
/* Add device */
- g_assert (nm_platform_dummy_add (DEVICE_NAME));
+ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
no_error ();
wait_signal (link_added);
/* Try to add again */
- g_assert (!nm_platform_dummy_add (DEVICE_NAME));
+ g_assert (!nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
error (NM_PLATFORM_ERROR_EXISTS);
/* Check device index, name and type */
- ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
g_assert (ifindex > 0);
- g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
- g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
- g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
+ g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex), ==, DEVICE_NAME);
+ g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_DUMMY);
+ g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, DUMMY_TYPEDESC);
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
/* Up/connected */
- g_assert (!nm_platform_link_is_up (ifindex)); no_error ();
- g_assert (!nm_platform_link_is_connected (ifindex)); no_error ();
- g_assert (nm_platform_link_set_up (ifindex)); no_error ();
- g_assert (nm_platform_link_is_up (ifindex)); no_error ();
- g_assert (nm_platform_link_is_connected (ifindex)); no_error ();
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
accept_signal (link_changed);
- g_assert (nm_platform_link_set_down (ifindex)); no_error ();
- g_assert (!nm_platform_link_is_up (ifindex)); no_error ();
- g_assert (!nm_platform_link_is_connected (ifindex)); no_error ();
+ g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
accept_signal (link_changed);
/* arp/noarp */
- g_assert (!nm_platform_link_uses_arp (ifindex));
- g_assert (nm_platform_link_set_arp (ifindex));
- g_assert (nm_platform_link_uses_arp (ifindex));
+ g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_set_arp (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
- g_assert (nm_platform_link_set_noarp (ifindex));
- g_assert (!nm_platform_link_uses_arp (ifindex));
+ g_assert (nm_platform_link_set_noarp (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
/* Features */
- g_assert (!nm_platform_link_supports_carrier_detect (ifindex));
- g_assert (nm_platform_link_supports_vlans (ifindex));
+ g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_supports_vlans (NM_PLATFORM_GET, ifindex));
/* Set MAC address */
- g_assert (nm_platform_link_set_address (ifindex, mac, sizeof (mac)));
- address = nm_platform_link_get_address (ifindex, &addrlen);
+ g_assert (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac)));
+ address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addrlen);
g_assert (addrlen == sizeof(mac));
g_assert (!memcmp (address, mac, addrlen));
- address = nm_platform_link_get_address (ifindex, NULL);
+ address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, NULL);
g_assert (!memcmp (address, mac, addrlen));
accept_signal (link_changed);
/* Set MTU */
- g_assert (nm_platform_link_set_mtu (ifindex, MTU));
+ g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU));
no_error ();
- g_assert_cmpint (nm_platform_link_get_mtu (ifindex), ==, MTU);
+ g_assert_cmpint (nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex), ==, MTU);
accept_signal (link_changed);
/* Delete device */
- g_assert (nm_platform_link_delete (ifindex));
+ g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
no_error ();
accept_signal (link_removed);
/* Try to delete again */
- g_assert (!nm_platform_link_delete (ifindex));
+ g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
error (NM_PLATFORM_ERROR_NOT_FOUND);
free_signal (link_added);
@@ -487,16 +487,16 @@ test_external (void)
run_command ("ip link add %s type %s", DEVICE_NAME, "dummy");
wait_signal (link_added);
- g_assert (nm_platform_link_exists (DEVICE_NAME));
- ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
g_assert (ifindex > 0);
- g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
- g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
- g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
+ g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex), ==, DEVICE_NAME);
+ g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_DUMMY);
+ g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, DUMMY_TYPEDESC);
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
- success = nm_platform_link_get (ifindex, &link);
+ success = nm_platform_link_get (NM_PLATFORM_GET, ifindex, &link);
g_assert (success);
if (!link.driver) {
/* we still lack the notification via UDEV. Expect another link changed signal. */
@@ -504,17 +504,17 @@ test_external (void)
}
/* Up/connected/arp */
- g_assert (!nm_platform_link_is_up (ifindex));
- g_assert (!nm_platform_link_is_connected (ifindex));
- g_assert (!nm_platform_link_uses_arp (ifindex));
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
run_command ("ip link set %s up", DEVICE_NAME);
wait_signal (link_changed);
- g_assert (nm_platform_link_is_up (ifindex));
- g_assert (nm_platform_link_is_connected (ifindex));
+ g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
run_command ("ip link set %s down", DEVICE_NAME);
wait_signal (link_changed);
- g_assert (!nm_platform_link_is_up (ifindex));
- g_assert (!nm_platform_link_is_connected (ifindex));
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
/* This test doesn't trigger a netlink event at least on
* 3.8.2-206.fc18.x86_64. Disabling the waiting and checking code
* because of that.
@@ -532,7 +532,7 @@ test_external (void)
run_command ("ip link del %s", DEVICE_NAME);
wait_signal (link_removed);
- g_assert (!nm_platform_link_exists (DEVICE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
free_signal (link_added);
free_signal (link_changed);
@@ -548,12 +548,12 @@ init_tests (int *argc, char ***argv)
void
setup_tests (void)
{
- nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
- nm_platform_link_delete (nm_platform_link_get_ifindex (SLAVE_NAME));
- nm_platform_link_delete (nm_platform_link_get_ifindex (PARENT_NAME));
- g_assert (!nm_platform_link_exists (DEVICE_NAME));
- g_assert (!nm_platform_link_exists (SLAVE_NAME));
- g_assert (!nm_platform_link_exists (PARENT_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, SLAVE_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, SLAVE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, PARENT_NAME));
g_test_add_func ("/link/bogus", test_bogus);
g_test_add_func ("/link/loopback", test_loopback);
diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
index af50db6754..85a119ddd0 100644
--- a/src/platform/tests/test-route.c
+++ b/src/platform/tests/test-route.c
@@ -53,7 +53,7 @@ ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *recei
static void
test_ip4_route_metric0 (void)
{
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback);
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback);
@@ -67,7 +67,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
/* add the first route */
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss));
no_error ();
accept_signal (route_added);
@@ -75,7 +75,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
/* Deleting route with metric 0 does nothing */
- g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, 0));
+ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
no_error ();
g_assert (!route_removed->received);
@@ -83,7 +83,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
/* add the second route */
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss));
no_error ();
accept_signal (route_added);
@@ -91,7 +91,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
/* Delete route with metric 0 */
- g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, 0));
+ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
no_error ();
accept_signal (route_removed);
@@ -99,7 +99,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
/* Delete route with metric 0 again (we expect nothing to happen) */
- g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, 0));
+ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
no_error ();
g_assert (!route_removed->received);
@@ -107,7 +107,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
/* Delete the other route */
- g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, metric));
+ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
accept_signal (route_removed);
@@ -122,7 +122,7 @@ test_ip4_route_metric0 (void)
static void
test_ip4_route (void)
{
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback);
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback);
@@ -139,40 +139,40 @@ test_ip4_route (void)
inet_pton (AF_INET, "198.51.100.1", &gateway);
/* Add route to gateway */
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss));
no_error ();
accept_signal (route_added);
/* Add route */
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
no_error ();
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
no_error ();
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
no_error ();
accept_signal (route_added);
/* Add route again */
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
no_error ();
accept_signal (route_changed);
/* Add default route */
assert_ip4_route_exists (FALSE, DEVICE_NAME, 0, 0, metric);
no_error ();
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
no_error ();
assert_ip4_route_exists (TRUE, DEVICE_NAME, 0, 0, metric);
no_error ();
accept_signal (route_added);
/* Add default route again */
- g_assert (nm_platform_ip4_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
+ g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
no_error ();
accept_signal (route_changed);
/* Test route listing */
- routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
memset (rts, 0, sizeof (rts));
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
rts[0].network = gateway;
@@ -201,13 +201,13 @@ test_ip4_route (void)
g_array_unref (routes);
/* Remove route */
- g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, metric));
+ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
accept_signal (route_removed);
/* Remove route again */
- g_assert (nm_platform_ip4_route_delete (ifindex, network, plen, metric));
+ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
free_signal (route_added);
@@ -218,7 +218,7 @@ test_ip4_route (void)
static void
test_ip6_route (void)
{
- int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_route_callback);
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_route_callback);
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_route_callback);
@@ -235,40 +235,40 @@ test_ip6_route (void)
inet_pton (AF_INET6, "2001:db8:c:d:1:2:3:4", &gateway);
/* Add route to gateway */
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss));
no_error ();
accept_signal (route_added);
/* Add route */
- g_assert (!nm_platform_ip6_route_exists (ifindex, network, plen, metric));
+ g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
no_error ();
- g_assert (nm_platform_ip6_route_exists (ifindex, network, plen, metric));
+ g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
accept_signal (route_added);
/* Add route again */
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
no_error ();
accept_signal (route_changed);
/* Add default route */
- g_assert (!nm_platform_ip6_route_exists (ifindex, in6addr_any, 0, metric));
+ g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric));
no_error ();
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
no_error ();
- g_assert (nm_platform_ip6_route_exists (ifindex, in6addr_any, 0, metric));
+ g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric));
no_error ();
accept_signal (route_added);
/* Add default route again */
- g_assert (nm_platform_ip6_route_add (ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
+ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
no_error ();
accept_signal (route_changed);
/* Test route listing */
- routes = nm_platform_ip6_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
+ routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
memset (rts, 0, sizeof (rts));
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
rts[0].network = gateway;
@@ -297,13 +297,13 @@ test_ip6_route (void)
g_array_unref (routes);
/* Remove route */
- g_assert (nm_platform_ip6_route_delete (ifindex, network, plen, metric));
+ g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
- g_assert (!nm_platform_ip6_route_exists (ifindex, network, plen, metric));
+ g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
accept_signal (route_removed);
/* Remove route again */
- g_assert (nm_platform_ip6_route_delete (ifindex, network, plen, metric));
+ g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
no_error ();
free_signal (route_added);
@@ -322,13 +322,13 @@ setup_tests (void)
{
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
- nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
- g_assert (!nm_platform_link_exists (DEVICE_NAME));
- g_assert (nm_platform_dummy_add (DEVICE_NAME));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
+ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
wait_signal (link_added);
free_signal (link_added);
- g_assert (nm_platform_link_set_up (nm_platform_link_get_ifindex (DEVICE_NAME)));
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
g_test_add_func ("/route/ip4", test_ip4_route);
g_test_add_func ("/route/ip6", test_ip6_route);
diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c
index 4a186dc815..17c9456e1b 100644
--- a/src/ppp-manager/nm-ppp-manager.c
+++ b/src/ppp-manager/nm-ppp-manager.c
@@ -546,7 +546,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
remove_timeout_handler (manager);
- config = nm_ip4_config_new (nm_platform_link_get_ifindex (priv->ip_iface));
+ config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface));
memset (&address, 0, sizeof (address));
address.plen = 32;
@@ -651,7 +651,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
remove_timeout_handler (manager);
- config = nm_ip6_config_new (nm_platform_link_get_ifindex (priv->ip_iface));
+ config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface));
memset (&addr, 0, sizeof (addr));
addr.plen = 64;
diff --git a/src/rdisc/nm-lndp-rdisc.c b/src/rdisc/nm-lndp-rdisc.c
index 922cb3dd76..a56be09edf 100644
--- a/src/rdisc/nm-lndp-rdisc.c
+++ b/src/rdisc/nm-lndp-rdisc.c
@@ -57,7 +57,7 @@ G_DEFINE_TYPE (NMLNDPRDisc, nm_lndp_rdisc, NM_TYPE_RDISC)
static inline gint32
ipv6_sysctl_get (const char *ifname, const char *property, gint32 defval)
{
- return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (ifname, property), defval);
+ return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, property), defval);
}
NMRDisc *
diff --git a/src/rdisc/tests/rdisc.c b/src/rdisc/tests/rdisc.c
index d577a63ae4..e05f34f970 100644
--- a/src/rdisc/tests/rdisc.c
+++ b/src/rdisc/tests/rdisc.c
@@ -60,10 +60,10 @@ main (int argc, char **argv)
if (argv[0]) {
ifname = argv[0];
- ifindex = nm_platform_link_get_ifindex (ifname);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname);
} else {
ifindex = 1;
- ifname = nm_platform_link_get_name (ifindex);
+ ifname = nm_platform_link_get_name (NM_PLATFORM_GET, ifindex);
}
rdisc = new (ifindex, ifname);
diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
index 9005a375f0..070b623997 100644
--- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
+++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
@@ -160,7 +160,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
if (!devtimeout)
return;
- if (nm_platform_link_get_ifindex (ifname) != 0)
+ if (nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname) != 0)
return;
/* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index febbd90ac6..1081ab8f81 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -4339,11 +4339,11 @@ is_wifi_device (const char *name, shvarFile *parsed)
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (parsed != NULL, FALSE);
- ifindex = nm_platform_link_get_ifindex (name);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, name);
if (ifindex == 0)
return FALSE;
- return nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_WIFI;
+ return nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) == NM_LINK_TYPE_WIFI;
}
static void
diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c
index 755767e296..8f528d0f4d 100644
--- a/src/settings/plugins/ifnet/net_parser.c
+++ b/src/settings/plugins/ifnet/net_parser.c
@@ -174,9 +174,9 @@ init_block_by_line (gchar * buf)
/* ignored connection */
conn = add_new_connection_config ("ignore", pos);
} else {
- int ifindex = nm_platform_link_get_ifindex (pos);
+ int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, pos);
- if (ifindex && nm_platform_link_get_type (ifindex) != NM_LINK_TYPE_WIFI)
+ if (ifindex && nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) != NM_LINK_TYPE_WIFI)
/* wired connection */
conn = add_new_connection_config ("wired", pos);
else
diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c
index 8332a8624c..4b12950fd7 100644
--- a/src/tests/test-route-manager.c
+++ b/src/tests/test-route-manager.c
@@ -75,7 +75,8 @@ setup_dev1_ip4 (int ifindex)
/* Add some route outside of route manager. The route manager
* should get rid of it upon sync. */
- nm_platform_ip4_route_add (route.ifindex,
+ nm_platform_ip4_route_add (NM_PLATFORM_GET,
+ route.ifindex,
NM_IP_CONFIG_SOURCE_USER,
nmtst_inet4_from_string ("9.0.0.0"),
8,
@@ -140,9 +141,11 @@ update_dev0_ip4 (int ifindex)
static GArray *
ip4_routes (test_fixture *fixture)
{
- GArray *routes = nm_platform_ip4_route_get_all (fixture->ifindex0,
+ GArray *routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET,
+ fixture->ifindex0,
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
- GArray *routes1 = nm_platform_ip4_route_get_all (fixture->ifindex1,
+ GArray *routes1 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET,
+ fixture->ifindex1,
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
g_array_append_vals (routes, routes1->data, routes1->len);
@@ -238,7 +241,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
};
setup_dev0_ip4 (fixture->ifindex0, 1000, 21021);
- g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 8.0.0.0/8 via 6.6.6.2 dev nm-test-device1 *");
+ g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 8.0.0.0/8 via 6.6.6.2 dev *");
setup_dev1_ip4 (fixture->ifindex1);
g_test_assert_expected_messages ();
@@ -250,7 +253,7 @@ test_ip4 (test_fixture *fixture, gconstpointer user_data)
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, state1, routes->len, TRUE);
g_array_free (routes, TRUE);
- g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 8.0.0.0/8 via 6.6.6.2 dev nm-test-device1 *");
+ g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 8.0.0.0/8 via 6.6.6.2 dev *");
setup_dev1_ip4 (fixture->ifindex1);
g_test_assert_expected_messages ();
@@ -298,7 +301,8 @@ setup_dev0_ip6 (int ifindex)
NMPlatformIP6Route *route;
/* Add an address so that a route to the gateway below gets added. */
- nm_platform_ip6_address_add (ifindex,
+ nm_platform_ip6_address_add (NM_PLATFORM_GET,
+ ifindex,
*nmtst_inet6_from_string ("2001:db8:8086::2"),
in6addr_any,
64,
@@ -345,7 +349,8 @@ setup_dev1_ip6 (int ifindex)
/* Add some route outside of route manager. The route manager
* should get rid of it upon sync. */
- nm_platform_ip6_route_add (ifindex,
+ nm_platform_ip6_route_add (NM_PLATFORM_GET,
+ ifindex,
NM_IP_CONFIG_SOURCE_USER,
*nmtst_inet6_from_string ("2001:db8:8088::"),
48,
@@ -400,7 +405,8 @@ update_dev0_ip6 (int ifindex)
NMPlatformIP6Route *route;
/* Add an address so that a route to the gateway below gets added. */
- nm_platform_ip6_address_add (ifindex,
+ nm_platform_ip6_address_add (NM_PLATFORM_GET,
+ ifindex,
*nmtst_inet6_from_string ("2001:db8:8086::2"),
in6addr_any,
64,
@@ -442,9 +448,11 @@ update_dev0_ip6 (int ifindex)
static GArray *
ip6_routes (test_fixture *fixture)
{
- GArray *routes = nm_platform_ip6_route_get_all (fixture->ifindex0,
+ GArray *routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET,
+ fixture->ifindex0,
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
- GArray *routes1 = nm_platform_ip6_route_get_all (fixture->ifindex1,
+ GArray *routes1 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET,
+ fixture->ifindex1,
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
g_array_append_vals (routes, routes1->data, routes1->len);
@@ -567,7 +575,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
};
setup_dev0_ip6 (fixture->ifindex0);
- g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 2001:db8:d34d::/64 via 2001:db8:8086::2 dev nm-test-device1 *");
+ g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 2001:db8:d34d::/64 via 2001:db8:8086::2 dev *");
setup_dev1_ip6 (fixture->ifindex1);
g_test_assert_expected_messages ();
@@ -581,7 +589,7 @@ test_ip6 (test_fixture *fixture, gconstpointer user_data)
g_array_free (routes, TRUE);
- g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 2001:db8:d34d::/64 via 2001:db8:8086::2 dev nm-test-device1 *");
+ g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*error adding 2001:db8:d34d::/64 via 2001:db8:8086::2 dev *");
setup_dev1_ip6 (fixture->ifindex1);
g_test_assert_expected_messages ();
setup_dev0_ip6 (fixture->ifindex0);
@@ -629,32 +637,32 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data)
NM_PLATFORM_SIGNAL_ADDED,
link_callback,
"nm-test-device0");
- nm_platform_link_delete (nm_platform_link_get_ifindex ("nm-test-device0"));
- g_assert (!nm_platform_link_exists ("nm-test-device0"));
- g_assert (nm_platform_dummy_add ("nm-test-device0"));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0"));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "nm-test-device0"));
+ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device0"));
wait_signal (link_added);
free_signal (link_added);
- fixture->ifindex0 = nm_platform_link_get_ifindex ("nm-test-device0");
- g_assert (nm_platform_link_set_up (fixture->ifindex0));
+ fixture->ifindex0 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0");
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex0));
link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED,
NM_PLATFORM_SIGNAL_ADDED,
link_callback,
"nm-test-device1");
- nm_platform_link_delete (nm_platform_link_get_ifindex ("nm-test-device1"));
- g_assert (!nm_platform_link_exists ("nm-test-device1"));
- g_assert (nm_platform_dummy_add ("nm-test-device1"));
+ nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1"));
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "nm-test-device1"));
+ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device1"));
wait_signal (link_added);
free_signal (link_added);
- fixture->ifindex1 = nm_platform_link_get_ifindex ("nm-test-device1");
- g_assert (nm_platform_link_set_up (fixture->ifindex1));
+ fixture->ifindex1 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1");
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex1));
}
static void
fixture_teardown (test_fixture *fixture, gconstpointer user_data)
{
- nm_platform_link_delete (fixture->ifindex0);
- nm_platform_link_delete (fixture->ifindex1);
+ nm_platform_link_delete (NM_PLATFORM_GET, fixture->ifindex0);
+ nm_platform_link_delete (NM_PLATFORM_GET, fixture->ifindex1);
}
void
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index 02c39c30f7..d24080452c 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -226,9 +226,9 @@ vpn_cleanup (NMVpnConnection *connection, NMDevice *parent_dev)
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
if (priv->ip_ifindex) {
- nm_platform_link_set_down (priv->ip_ifindex);
+ nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex);
nm_route_manager_route_flush (nm_route_manager_get (), priv->ip_ifindex);
- nm_platform_address_flush (priv->ip_ifindex);
+ nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex);
}
nm_device_set_vpn4_config (parent_dev, NULL);
@@ -921,7 +921,7 @@ nm_vpn_connection_apply_config (NMVpnConnection *connection)
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
if (priv->ip_ifindex > 0) {
- nm_platform_link_set_up (priv->ip_ifindex);
+ nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex);
if (priv->ip4_config) {
if (!nm_ip4_config_commit (priv->ip4_config, priv->ip_ifindex,
@@ -1037,7 +1037,7 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
if (priv->ip_iface) {
/* Grab the interface index for address/routing operations */
- priv->ip_ifindex = nm_platform_link_get_ifindex (priv->ip_iface);
+ priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
if (!priv->ip_ifindex) {
nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface);
nm_vpn_connection_config_maybe_complete (self, FALSE);