diff options
author | guoqiang.liu <guoqiang.liu@archermind.com> | 2013-10-12 11:21:03 +0800 |
---|---|---|
committer | Zhang zhengguang <zhengguang.zhang@intel.com> | 2013-10-28 13:22:51 +0800 |
commit | a3ad08e36f0c3bd21fb742f09e2754d6bc446641 (patch) | |
tree | af5e2460b1c5d7d47f5c2157a54c40f00689cbb1 | |
parent | b711e972313e8ffd59ab8fc7d20980eaae33dbfa (diff) | |
download | connman-a3ad08e36f0c3bd21fb742f09e2754d6bc446641.tar.gz connman-a3ad08e36f0c3bd21fb742f09e2754d6bc446641.tar.bz2 connman-a3ad08e36f0c3bd21fb742f09e2754d6bc446641.zip |
Tethering: Add gadget device rtnl handler
The technology will not power on despite gadget interface is
up, add rtnl handler to fix it.
Change-Id: I25409db8793fd79c1e6b1248a7d919701890ed4d
-rw-r--r-- | plugins/ethernet.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/ethernet.c b/plugins/ethernet.c index 4f23e752..aa4edfae 100644 --- a/plugins/ethernet.c +++ b/plugins/ethernet.c @@ -226,14 +226,57 @@ static struct connman_device_driver ethernet_driver = { .disable = ethernet_disable, }; +static void gadget_newlink(unsigned flags, unsigned change, void *user_data) +{ + struct connman_device *device = user_data; + struct ethernet_data *ethernet = connman_device_get_data(device); + + DBG("index %d flags %d change %d", ethernet->index, flags, change); + + 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); + } + } + + ethernet->flags = flags; +} + static int gadget_probe(struct connman_device *device) { + struct ethernet_data *ethernet; + DBG("device %p", device); + + ethernet = g_try_new0(struct ethernet_data, 1); + if (ethernet == NULL) + return -ENOMEM; + + connman_device_set_data(device, ethernet); + + ethernet->index = connman_device_get_index(device); + ethernet->flags = 0; + + ethernet->watch = connman_rtnl_add_newlink_watch(ethernet->index, + gadget_newlink, device); + return 0; } static void gadget_remove(struct connman_device *device) { + struct ethernet_data *ethernet = connman_device_get_data(device); + DBG("device %p", device); + + connman_device_set_data(device, NULL); + + connman_rtnl_remove_watch(ethernet->watch); + + g_free(ethernet); } static int gadget_enable(struct connman_device *device) { |