core: turn link_changed() into a proper virtual function

This commit is contained in:
Pavel Šimerda
2013-07-27 10:41:44 +02:00
parent 5767af2601
commit 0e361e894c
5 changed files with 24 additions and 10 deletions

View File

@@ -59,12 +59,14 @@ enum {
/**************************************************************/ /**************************************************************/
static void static void
link_changed (NMDevice *device) link_changed (NMDevice *device, NMPlatformLink *info)
{ {
NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (device); NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (device);
GObject *object = G_OBJECT (device); GObject *object = G_OBJECT (device);
NMPlatformGreProperties props; NMPlatformGreProperties props;
NM_DEVICE_CLASS (nm_device_gre_parent_class)->link_changed (device, info);
if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) { if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) {
nm_log_warn (LOGD_HW, "(%s): could not read gre properties", nm_log_warn (LOGD_HW, "(%s): could not read gre properties",
nm_device_get_iface (device)); nm_device_get_iface (device));
@@ -128,7 +130,7 @@ nm_device_gre_init (NMDeviceGre *self)
static void static void
constructed (GObject *object) constructed (GObject *object)
{ {
link_changed (NM_DEVICE (object)); link_changed (NM_DEVICE (object), NULL);
G_OBJECT_CLASS (nm_device_gre_parent_class)->constructed (object); G_OBJECT_CLASS (nm_device_gre_parent_class)->constructed (object);
} }

View File

@@ -54,12 +54,14 @@ enum {
/**************************************************************/ /**************************************************************/
static void static void
link_changed (NMDevice *device) link_changed (NMDevice *device, NMPlatformLink *info)
{ {
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device);
GObject *object = G_OBJECT (device); GObject *object = G_OBJECT (device);
NMPlatformMacvlanProperties props; NMPlatformMacvlanProperties props;
NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->link_changed (device, info);
if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) { if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) {
nm_log_warn (LOGD_HW, "(%s): could not read macvlan properties", nm_log_warn (LOGD_HW, "(%s): could not read macvlan properties",
nm_device_get_iface (device)); nm_device_get_iface (device));
@@ -108,7 +110,7 @@ nm_device_macvlan_init (NMDeviceMacvlan *self)
static void static void
constructed (GObject *object) constructed (GObject *object)
{ {
link_changed (NM_DEVICE (object)); link_changed (NM_DEVICE (object), NULL);
G_OBJECT_CLASS (nm_device_macvlan_parent_class)->constructed (object); G_OBJECT_CLASS (nm_device_macvlan_parent_class)->constructed (object);
} }

View File

@@ -53,12 +53,14 @@ enum {
}; };
static void static void
link_changed (NMDevice *device) link_changed (NMDevice *device, NMPlatformLink *info)
{ {
NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (device);
GObject *object = G_OBJECT (device); GObject *object = G_OBJECT (device);
NMPlatformTunProperties props; NMPlatformTunProperties props;
NM_DEVICE_CLASS (nm_device_tun_parent_class)->link_changed (device, info);
if (!nm_platform_tun_get_properties (nm_device_get_ifindex (device), &props)) { if (!nm_platform_tun_get_properties (nm_device_get_ifindex (device), &props)) {
nm_log_warn (LOGD_HW, "(%s): could not read tun properties", nm_log_warn (LOGD_HW, "(%s): could not read tun properties",
nm_device_get_iface (device)); nm_device_get_iface (device));

View File

@@ -1151,15 +1151,21 @@ nm_device_set_carrier (NMDevice *device, gboolean carrier)
static void static void
link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMDevice *device) link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMDevice *device)
{ {
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
if (ifindex != nm_device_get_ifindex (device)) if (ifindex != nm_device_get_ifindex (device))
return; return;
if (klass->link_changed)
klass->link_changed (device, info);
}
static void
link_changed (NMDevice *device, NMPlatformLink *info)
{
if ( device_has_capability (device, NM_DEVICE_CAP_CARRIER_DETECT) if ( device_has_capability (device, NM_DEVICE_CAP_CARRIER_DETECT)
&& !device_has_capability (device, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) && !device_has_capability (device, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
nm_device_set_carrier (device, info->connected); nm_device_set_carrier (device, info->connected);
if (NM_DEVICE_GET_CLASS (device)->link_changed)
NM_DEVICE_GET_CLASS (device)->link_changed (device);
} }
static void static void
@@ -5124,6 +5130,8 @@ nm_device_class_init (NMDeviceClass *klass)
object_class->constructor = constructor; object_class->constructor = constructor;
object_class->constructed = constructed; object_class->constructed = constructed;
klass->link_changed = link_changed;
klass->is_available = is_available; klass->is_available = is_available;
klass->act_stage1_prepare = act_stage1_prepare; klass->act_stage1_prepare = act_stage1_prepare;
klass->act_stage2_config = act_stage2_config; klass->act_stage2_config = act_stage2_config;

View File

@@ -101,6 +101,8 @@ typedef struct {
NMDeviceState old_state, NMDeviceState old_state,
NMDeviceStateReason reason); NMDeviceStateReason reason);
void (* link_changed) (NMDevice *self, NMPlatformLink *info);
/* Hardware state (IFF_UP) */ /* Hardware state (IFF_UP) */
gboolean (*is_up) (NMDevice *self); gboolean (*is_up) (NMDevice *self);
gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware); gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware);
@@ -186,8 +188,6 @@ typedef struct {
gboolean (* have_any_ready_slaves) (NMDevice *self, gboolean (* have_any_ready_slaves) (NMDevice *self,
const GSList *slaves); const GSList *slaves);
void (* link_changed) (NMDevice *self);
} NMDeviceClass; } NMDeviceClass;