From patchwork Fri Feb 26 09:38:37 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: 588736 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 4B8E01402A8 for ; Fri, 26 Feb 2016 20:50:42 +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=RH7aVV/s; 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 1aZF2f-0002wW-DS; Fri, 26 Feb 2016 09:50:33 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZF2d-0002kI-G6 for hostap@bombadil.infradead.org; Fri, 26 Feb 2016 09:50:31 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by casper.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1aZEsC-0002vL-Dq for hostap@lists.infradead.org; Fri, 26 Feb 2016 09:39:45 +0000 Received: by mail-wm0-x230.google.com with SMTP id b205so64713628wmb.1 for ; Fri, 26 Feb 2016 01:39:24 -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=vvhY0B9YkLRFXCFVJ4OQiKlw4gDPF2Rc9SaHh2HsXfc=; b=RH7aVV/snh6SMIvzkvyLgwrKz9EbZ/Ks3yH7e//dzNi2n8wm4mhLmVPXgshOgGjrIc CWa2lgahHghhW1XiWBHeiXoXXg6FXuJAOK9dfXtDvEw9VAf8QLy7GUdhv3gdvaBQDNdJ 6uU2xYWSWjk1wio+FGgbXHgs1RN+fIDQa1E+g= 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=vvhY0B9YkLRFXCFVJ4OQiKlw4gDPF2Rc9SaHh2HsXfc=; b=KqhjEHCLuJZJgNYWQjG9I4qNaI0pCvzExBfrR+DtcWhBtQc2JtCCBS/+c1+TDAgjLD +HP7Y98p1moXy+wABmAKpQY6huUNkaufRjkUJ93NPNY4sz51nKpAczRW74FJqB17oG4v SIdDlmU6+EpkZI9Hz1ZunaaC9ELSAqiy7Rm2ZDYe/JVnee8MC+HVxjBiGtDsVxW8vo6w 2aNifaMz1xYtkqHKPZTCeZbiJTu/ybxkuhD28qyHlGZF0Jicau5ujsHpfYrRY+HSrdVd pIo5JSMwBVqhbtX+9OD25+GqIN2D5yEA02C0nXMCIpnlKgmzVvBkP58lEty8b/yyuqt/ wefw== X-Gm-Message-State: AD7BkJKZ7CmBiaZcFunCCHkNBaw+Q6mG4DIrlzPedeHZcxz4vGnyeAYU4xk2Xia4K1EpjcOc6Q428XD0YbaconaNigj8wlQEsBwhn8pDvxyzWM/qyh002yVzBIufxGXW3m0fPXI2apG8H2mMK6kc51JgvG0bg5jdVoN6LrYOiw6BsTFRmwnYle/ay4VQZ9lXrPK6 X-Received: by 10.194.174.197 with SMTP id bu5mr708014wjc.23.1456479563107; Fri, 26 Feb 2016 01:39:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 01:39:22 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v4 22/29] tests: hostapd.py add get_ctrl_iface_port Date: Fri, 26 Feb 2016 10:38:37 +0100 Message-Id: <1456479524-14185-23-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_093944_519700_017F26CD X-CRM114-Status: UNSURE ( 9.74 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on casper.infradead.org summary: Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:230 listed in] [list.dnswl.org] -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_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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Add method to get UDP port for required iface. Signed-off-by: Janusz Dziedzic --- tests/hwsim/hostapd.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 5368386..e4d6bc8 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -82,6 +82,25 @@ class HostapdGlobal: def flush(self): self.ctrl.request("FLUSH") + def get_ctrl_iface_port(self, ifname): + res = -1 + if self.hostname is None: + return None + + res = self.ctrl.request("INTERFACES ctrl") + lines = res.splitlines() + for line in lines: + words = line.split() + if words[0] == ifname: + res = 1 + break + if res == -1: + raise Exception("Could not find UDP port for " + ifname) + res = line.find("ctrl_iface=udp:") + if res == -1: + raise Exception("Wrong ctrl_interace format") + words = line.split(":") + return int(words[1]) class Hostapd: def __init__(self, ifname, bssidx=0, hostname=None, port=8877): @@ -293,7 +312,8 @@ def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30, hostn hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.remove(ifname) hapd_global.add(ifname) - hapd = Hostapd(ifname, hostname=hostname) + port = hapd_global.get_ctrl_iface_port(ifname) + hapd = Hostapd(ifname, hostname=hostname, port=port) if not hapd.ping(): raise Exception("Could not ping hostapd") hapd.set_defaults() @@ -327,7 +347,8 @@ def add_bss(phy, ifname, confname, ignore_error=False, hostname=None, port=8878) logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.add_bss(phy, confname, ignore_error) - hapd = Hostapd(ifname, hostname=hostname) + port = hapd_global.get_ctrl_iface_port(ifname) + hapd = Hostapd(ifname, hostname=hostname, port=port) if not hapd.ping(): raise Exception("Could not ping hostapd") @@ -335,7 +356,8 @@ def add_iface(ifname, confname, hostname=None, port=8878): logger.info("Starting interface " + ifname) hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.add_iface(ifname, confname) - hapd = Hostapd(ifname, hostname=hostname) + port = hapd_global.get_ctrl_iface_port(ifname) + hapd = Hostapd(ifname, hostname=hostname, port=port) if not hapd.ping(): raise Exception("Could not ping hostapd")