diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-12-25 04:27:23 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-12-25 04:27:23 +0100 |
commit | e29b62b9491e0d4a0ad3d47de9a5ce47df93f2b5 (patch) | |
tree | 0479f2802da3f554d0eb10df6b42e1f7a1a97398 /plugins/ethernet.c | |
parent | 899be488360ad24f079bbb204dc32a47c6aae093 (diff) | |
download | connman-e29b62b9491e0d4a0ad3d47de9a5ce47df93f2b5.tar.gz connman-e29b62b9491e0d4a0ad3d47de9a5ce47df93f2b5.tar.bz2 connman-e29b62b9491e0d4a0ad3d47de9a5ce47df93f2b5.zip |
Use device helpers to set power and carrier states
Diffstat (limited to 'plugins/ethernet.c')
-rw-r--r-- | plugins/ethernet.c | 61 |
1 files changed, 19 insertions, 42 deletions
diff --git a/plugins/ethernet.c b/plugins/ethernet.c index 0b70462f..08cfb4fe 100644 --- a/plugins/ethernet.c +++ b/plugins/ethernet.c @@ -43,43 +43,6 @@ struct ethernet_data { static GSList *ethernet_list = NULL; -static void update_power(struct connman_device *device, unsigned flags) -{ - if (flags & IFF_UP) { - DBG("power on"); - - connman_device_set_powered(device, TRUE); - } else { - DBG("power off"); - - connman_device_set_powered(device, FALSE); - } -} - -static void update_carrier(struct connman_device *device, unsigned flags) -{ - struct connman_element *netdev; - - if (flags & IFF_LOWER_UP) { - DBG("carrier on"); - - netdev = connman_element_create(NULL); - if (netdev != NULL) { - netdev->type = CONNMAN_ELEMENT_TYPE_DEVICE; - netdev->subtype = CONNMAN_ELEMENT_SUBTYPE_NETWORK; - netdev->index = device->element->index; - - if (connman_element_register(netdev, - device->element) < 0) - connman_element_unref(netdev); - } - } else { - DBG("carrier off"); - - connman_element_unregister_children(device->element); - } -} - static void ethernet_newlink(unsigned short type, int index, unsigned flags, unsigned change) { @@ -98,11 +61,25 @@ static void ethernet_newlink(unsigned short type, int index, if (ethernet->index != index) continue; - if ((ethernet->flags & IFF_UP) != (flags & IFF_UP)) - update_power(device, flags); + if ((ethernet->flags & IFF_UP) != (flags & IFF_UP)) { + if (flags & IFF_UP) { + DBG("power on"); + connman_device_set_powered(device, TRUE); + } else { + DBG("power off"); + connman_device_set_powered(device, FALSE); + } + } - if ((ethernet->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) - update_carrier(device, flags); + if ((ethernet->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) { + if (flags & IFF_LOWER_UP) { + DBG("carrier on"); + connman_device_set_carrier(device, TRUE); + } else { + DBG("carrier off"); + connman_device_set_carrier(device, FALSE); + } + } ethernet->flags = flags; } @@ -213,7 +190,7 @@ static int ethernet_probe(struct connman_device *device) connman_device_set_data(device, ethernet); - ethernet->index = device->element->index; + ethernet->index = connman_device_get_index(device); connman_rtnl_send_getlink(); |