From 35d0c519d763c499a15a742261ffaaa731f6b854 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 12 Jan 2015 17:52:37 +0200 Subject: [PATCH] scan: Refactor scan start details to scan.c Move the implementation details of triggering wifi scans over netlink to scan.c from wiphy.c. No functionality is changed by this commit. --- Makefile.am | 1 + src/scan.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/scan.h | 26 ++++++++++++++++++++++++++ src/wiphy.c | 7 ++----- 4 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/scan.c create mode 100644 src/scan.h diff --git a/Makefile.am b/Makefile.am index 695b7cf9..17267af8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h linux/kdbus.h \ src/crypto.h src/crypto.c \ src/mpdu.h src/mpdu.c \ src/eapol.h src/eapol.c \ + src/scan.h src/scan.c \ iwd.h src_iwd_LDADD = ell/libell-internal.la diff --git a/src/scan.c b/src/scan.c new file mode 100644 index 00000000..005f42eb --- /dev/null +++ b/src/scan.c @@ -0,0 +1,49 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2015 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "linux/nl80211.h" +#include "src/iwd.h" +#include "src/wiphy.h" +#include "src/scan.h" + +void scan_start(struct l_genl_family *nl80211, uint32_t ifindex, + scan_func_t callback, void *user_data) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_TRIGGER_SCAN, 16); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + l_genl_family_send(nl80211, msg, callback, user_data, NULL); + l_genl_msg_unref(msg); +} diff --git a/src/scan.h b/src/scan.h new file mode 100644 index 00000000..f71e6bb0 --- /dev/null +++ b/src/scan.h @@ -0,0 +1,26 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2015 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +typedef void (*scan_func_t)(struct l_genl_msg *msg, void *user_data); + +void scan_start(struct l_genl_family *nl80211, uint32_t ifindex, + scan_func_t callback, void *user_data); diff --git a/src/wiphy.c b/src/wiphy.c index d450cb33..f644d77b 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -37,6 +37,7 @@ #include "src/ie.h" #include "src/wiphy.h" #include "src/dbus.h" +#include "src/scan.h" static struct l_genl *genl = NULL; static struct l_genl_family *nl80211 = NULL; @@ -390,17 +391,13 @@ static struct l_dbus_message *device_scan(struct l_dbus *dbus, void *user_data) { struct netdev *netdev = user_data; - struct l_genl_msg *msg; if (netdev->pending) return dbus_error_busy(message); netdev->pending = l_dbus_message_ref(message); - msg = l_genl_msg_new_sized(NL80211_CMD_TRIGGER_SCAN, 16); - msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); - l_genl_family_send(nl80211, msg, device_scan_callback, netdev, NULL); - l_genl_msg_unref(msg); + scan_start(nl80211, netdev->index, device_scan_callback, netdev); return NULL; }