__connman_udev_get_block_state() can be used to check block state. --- src/connman.h | 1 + src/udev.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/src/connman.h b/src/connman.h index a6619df..7b9ab6a 100644 --- a/src/connman.h +++ b/src/connman.h @@ -265,6 +265,7 @@ char *__connman_udev_get_devtype(const char *ifname); char *__connman_udev_get_mbm_devnode(const char *ifname); void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked); void __connman_udev_enable_rfkill_processing(void); +connman_bool_t __connman_udev_get_block_state(int phyindex); #include <connman/device.h> diff --git a/src/udev.c b/src/udev.c index 59f36ea..783cdb3 100644 --- a/src/udev.c +++ b/src/udev.c @@ -155,6 +155,58 @@ static void remove_net_device(struct udev_device *udev_device) connman_device_unref(device); } +static GSList *block_list = NULL; + +struct block_data { + int phyindex; + connman_bool_t blocked; +}; + +connman_bool_t __connman_udev_get_block_state(int phyindex) +{ + GSList *list; + + if (phyindex < 0) + return FALSE; + + for (list = block_list; list; list = block_list->next) { + struct block_data *block = list->data; + + if (block->phyindex == phyindex) + return block->blocked; + } + + return FALSE; +} + +static void update_rfkill_state(int phyindex, connman_bool_t blocked) +{ + GSList *list; + struct block_data *block; + + DBG("index %d blocked %d", phyindex, blocked); + + for (list = block_list; list; list = block_list->next) { + block = list->data; + + if (block->phyindex == phyindex) { + block->blocked = blocked; + return; + } + } + + block = g_try_new0(struct block_data, 1); + if (block == NULL) + return; + + block->phyindex = phyindex; + block->blocked = blocked; + + block_list = g_slist_append(block_list, block); + + return; +} + static void phyindex_rfkill(int phyindex, connman_bool_t blocked) { GSList *list; @@ -162,6 +214,8 @@ static void phyindex_rfkill(int phyindex, connman_bool_t blocked) if (phyindex < 0) return; + update_rfkill_state(phyindex, blocked); + for (list = device_list; list; list = list->next) { struct connman_device *device = list->data; @@ -543,6 +597,14 @@ void __connman_udev_cleanup(void) g_slist_free(device_list); device_list = NULL; + for (list = block_list; list; list = list->next) { + struct block_data *block = list->data; + g_free(block); + } + + g_slist_free(block_list); + block_list = NULL; + if (udev_ctx == NULL) return; -- 1.6.1.3 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman