From patchwork Fri Jun 12 14:00:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 6598901 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DE984C0020 for ; Fri, 12 Jun 2015 14:01:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0ABDD2034A for ; Fri, 12 Jun 2015 14:01:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2AAFA2066F for ; Fri, 12 Jun 2015 14:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754925AbbFLOBJ (ORCPT ); Fri, 12 Jun 2015 10:01:09 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:59257 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753726AbbFLOBD (ORCPT ); Fri, 12 Jun 2015 10:01:03 -0400 Received: from a88-113-225-236.elisa-laajakaista.fi ([88.113.225.236] helo=localhost.localdomain) by farmhouse.coelho.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.85) (envelope-from ) id 1Z3PVz-00057K-Ql; Fri, 12 Jun 2015 17:01:00 +0300 From: Luca Coelho To: aspriel@gmail.com Cc: linux-wireless@vger.kernel.org Date: Fri, 12 Jun 2015 17:00:44 +0300 Message-Id: <1434117644-3033-5-git-send-email-luca@coelho.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434117644-3033-1-git-send-email-luca@coelho.fi> References: <1434117644-3033-1-git-send-email-luca@coelho.fi> X-SA-Exim-Connect-IP: 88.113.225.236 X-SA-Exim-Mail-From: luca@coelho.fi X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Subject: [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on farmhouse.coelho.fi) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luciano Coelho Modify the sched_scan_start class so that the caller can pass a list of matches to be used in the scheduled scan request. Signed-off-by: Luciano Coelho --- lib/scan.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/scan.py b/lib/scan.py index bfaf3d2..b55d148 100644 --- a/lib/scan.py +++ b/lib/scan.py @@ -192,10 +192,34 @@ class sched_scan_start(scan_start_base): def __init__(self, ifidx, level=nl.NL_CB_DEFAULT): super(sched_scan_start, self).__init__(ifidx, level) self._nl_cmd = nl80211.CMD_START_SCHED_SCAN + self._matches = None def set_interval(self, interval): self._interval = interval + def add_matches(self, matches): + self._matches = matches + + def _add_matches_attrs(self): + if self._matches: + i = 0 + + matchset = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCHED_SCAN_MATCH) + for match in self._matches: + nest = nl.nla_nest_start(self._nl_msg._msg, i) + if 'ssid' in match: + nl.nla_put(self._nl_msg._msg, nl80211.SCHED_SCAN_MATCH_ATTR_SSID, match['ssid']) + i += 1 + nl.nla_nest_end(self._nl_msg._msg, nest) + + nl.nla_nest_end(self._nl_msg._msg, matchset) + + def send(self): + self._prepare_cmd() + self._add_scan_attrs() + self._add_matches_attrs() + self._send_and_wait() + def handle(self, msg, arg): genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))