From patchwork Fri Feb 26 09:38:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 588724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2DB0B140271 for ; Fri, 26 Feb 2016 20:40:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=tieto.com header.i=@tieto.com header.b=SIIz7Hkp; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZEsW-0004g7-NT; Fri, 26 Feb 2016 09:40:04 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZEs9-000490-Gu for hostap@lists.infradead.org; Fri, 26 Feb 2016 09:39:43 +0000 Received: by mail-wm0-x230.google.com with SMTP id c200so64323848wme.0 for ; Fri, 26 Feb 2016 01:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3oZ2VRTqx2crnE6I+kD7f9iRSMt2rPFvH+JBV9F9ECk=; b=SIIz7HkpqL7I9qqjpfT/wjbqjs2xMtsehEBO2gsZys5LOWr1TRCPWNfu9gtg+EVaj8 558EJyCRBurmh8iXRl4mXuDiPiPZpeAm+zD03UJe1ebY+nn/Jal5jA0NUkNBNQZCYAhr Mp604aHvkbHJC+tm55M+2TCwHO3M/kgK3FhqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3oZ2VRTqx2crnE6I+kD7f9iRSMt2rPFvH+JBV9F9ECk=; b=Ulrn8MM59YHrBCr/NimTMkAn1QxTCZFAwMZUmsmuMlkkpO04Is5KaCyNIHdjS7bj8j DMY9KZjK2djvR7mRdEzbm0krqqarqnLrcLteiQlKeQOlbt5mQLnmHoot0TBnCqS0cnwe PIAXMPAk4pb9VruEZSAX79Y44WByhRxm77XAhyWOB2hL00onbnQloYu/oM06TkgV9b4r DA/3dvVmBG1jiw1MS7XUi3hnrX7sfCojcc5z5r5RbkVQC5FB2icZRRexrn3iDzw31vTI UHblMR7c03pIUT9FSEzy7kMFVr4mUeoCN0fUtDxnZswVZZF2G03F7Z4LWvsrDXI1c2dx sEAQ== X-Gm-Message-State: AD7BkJLMnJ9bfqvOQrrm9fVds23iZZ6fMPWLFWwT5T8RwV0G6XUklidFQQGccMhYKC+qXd5SIgUPag/ZOr/aDxuRZ/xkZfSmwtd3MVonCrqSpldiWrXa9TV5G3U3ic4sxi/PJninXwCkzYocdcBzaLsryibdx6Udcgth4nu+5jfzyN0r9fXck8ZJNo7WyNFa81ui X-Received: by 10.28.174.8 with SMTP id x8mr2123835wme.49.1456479559897; Fri, 26 Feb 2016 01:39:19 -0800 (PST) Received: from dell6430.guest.wifi ([91.198.246.8]) by smtp.gmail.com with ESMTPSA id z65sm1915950wmg.1.2016.02.26.01.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 01:39:19 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v4 19/29] tests: hostapd.py allow to use remote host Date: Fri, 26 Feb 2016 10:38:34 +0100 Message-Id: <1456479524-14185-20-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456479524-14185-1-git-send-email-janusz.dziedzic@tieto.com> References: <1456479524-14185-1-git-send-email-janusz.dziedzic@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160226_013941_980763_A9663FE3 X-CRM114-Status: UNSURE ( 9.06 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@w1.fi, Janusz Dziedzic MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Allow to use remote host with wpaspy.Ctrl with UDP support. Signed-off-by: Janusz Dziedzic --- tests/hwsim/hostapd.py | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 4613efe..06bc4a7 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -19,9 +19,15 @@ def mac2tuple(mac): return struct.unpack('6B', binascii.unhexlify(mac.replace(':',''))) class HostapdGlobal: - def __init__(self): - self.ctrl = wpaspy.Ctrl(hapd_global) - self.mon = wpaspy.Ctrl(hapd_global) + def __init__(self, hostname=None, port=8878): + self.hostname = hostname + self.port = port + if hostname is None: + self.ctrl = wpaspy.Ctrl(hapd_global) + self.mon = wpaspy.Ctrl(hapd_global) + else: + self.ctrl = wpaspy.Ctrl(hostname, port) + self.mon = wpaspy.Ctrl(hostname, port) self.mon.attach() def request(self, cmd): @@ -77,10 +83,15 @@ class HostapdGlobal: class Hostapd: - def __init__(self, ifname, bssidx=0): + def __init__(self, ifname, bssidx=0, hostname=None, port=8877): self.ifname = ifname - self.ctrl = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname)) - self.mon = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname)) + + if hostname is None: + self.ctrl = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname)) + self.mon = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname)) + else: + self.ctrl = wpaspy.Ctrl(hostname, port) + self.mon = wpaspy.Ctrl(hostname, port) self.mon.attach() self.bssid = None self.bssidx = bssidx @@ -275,12 +286,12 @@ class Hostapd: vals[name_val[0]] = name_val[1] return vals -def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30): +def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30, hostname=None, port=8878): logger.info("Starting AP " + ifname) - hapd_global = HostapdGlobal() + hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.remove(ifname) hapd_global.add(ifname) - hapd = Hostapd(ifname) + hapd = Hostapd(ifname, hostname=hostname) if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults() @@ -310,25 +321,25 @@ def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30): raise Exception("AP startup failed") return hapd -def add_bss(phy, ifname, confname, ignore_error=False): +def add_bss(phy, ifname, confname, ignore_error=False, hostname=None, port=8878): logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) - hapd_global = HostapdGlobal() + hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.add_bss(phy, confname, ignore_error) - hapd = Hostapd(ifname) + hapd = Hostapd(ifname, hostname=hostname) if not hapd.ping(): raise Exception("Could not ping hostapd") -def add_iface(ifname, confname): +def add_iface(ifname, confname, hostname=None, port=8878): logger.info("Starting interface " + ifname) - hapd_global = HostapdGlobal() + hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.add_iface(ifname, confname) - hapd = Hostapd(ifname) + hapd = Hostapd(ifname, hostname=hostname) if not hapd.ping(): raise Exception("Could not ping hostapd") -def remove_bss(ifname): +def remove_bss(ifname, hostname=None, port=8878): logger.info("Removing BSS " + ifname) - hapd_global = HostapdGlobal() + hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.remove(ifname) def wpa2_params(ssid=None, passphrase=None):