3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-28 21:19:24 +01:00

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.
This commit is contained in:
Jukka Rissanen 2015-01-12 17:52:37 +02:00 committed by Denis Kenzior
parent 78d21c782c
commit 35d0c519d7
4 changed files with 78 additions and 5 deletions

View File

@ -53,6 +53,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h linux/kdbus.h \
src/crypto.h src/crypto.c \ src/crypto.h src/crypto.c \
src/mpdu.h src/mpdu.c \ src/mpdu.h src/mpdu.c \
src/eapol.h src/eapol.c \ src/eapol.h src/eapol.c \
src/scan.h src/scan.c \
iwd.h iwd.h
src_iwd_LDADD = ell/libell-internal.la src_iwd_LDADD = ell/libell-internal.la

49
src/scan.c Normal file
View File

@ -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 <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <ell/ell.h>
#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);
}

26
src/scan.h Normal file
View File

@ -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);

View File

@ -37,6 +37,7 @@
#include "src/ie.h" #include "src/ie.h"
#include "src/wiphy.h" #include "src/wiphy.h"
#include "src/dbus.h" #include "src/dbus.h"
#include "src/scan.h"
static struct l_genl *genl = NULL; static struct l_genl *genl = NULL;
static struct l_genl_family *nl80211 = 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) void *user_data)
{ {
struct netdev *netdev = user_data; struct netdev *netdev = user_data;
struct l_genl_msg *msg;
if (netdev->pending) if (netdev->pending)
return dbus_error_busy(message); return dbus_error_busy(message);
netdev->pending = l_dbus_message_ref(message); netdev->pending = l_dbus_message_ref(message);
msg = l_genl_msg_new_sized(NL80211_CMD_TRIGGER_SCAN, 16); scan_start(nl80211, netdev->index, device_scan_callback, netdev);
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);
return NULL; return NULL;
} }