From patchwork Fri Mar 4 09:20:38 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: 591861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 6F6E014018C for ; Fri, 4 Mar 2016 20:26:16 +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=B3X0Fh1h; 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 1ablzu-00056I-1p; Fri, 04 Mar 2016 09:26:10 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ablvW-00021u-1P for hostap@bombadil.infradead.org; Fri, 04 Mar 2016 09:21:38 +0000 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1ablvU-0007zc-Rk for hostap@lists.infradead.org; Fri, 04 Mar 2016 09:21:37 +0000 Received: by mail-lb0-x22f.google.com with SMTP id bc4so53975071lbc.2 for ; Fri, 04 Mar 2016 01:21:16 -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=B3X0Fh1h6qLK0xbb2c8Vmrd4TDS7EYwJTcKOpy2w8N/1VP8UHcGkmKqcb/MqHub0iR 0b+o6FS2ddpw0eiOYdlKuc90tHud8GtPnRAsQfLWN9L0aDpJF0SY7QeFFrTMdEYAvx6/ HqgjyFrIk4Cw3okbBszaE9438tk9levyaiJ90= 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=kechqXi9wsAh9cdRwuapouxcPUejYBnPMM73I4Opgsj0oaGfRJxhyXq6PE5qRhSSQ3 IcT65JUzF2wGFoiOD/Z9OWBIp7kzEPtj71W74THjSP8zyHJStU6y65tswj6VRhxe/Ai0 JlpsCKjwc6YaSgi0fQJz+gPWfuyYWX5Dw07XMk7fiM4TxWSkhAzeo+zFOQhJqq5eLS8J 1Xd5ZuKu6WWtuB8gW4zoTNMT8oUft7dUCmPyK2m3KOYLHxUKxTwAGMGJcrHtdVnvRud5 G2r0I/aM07tahVMrSqreNTLOwGgq53K5YgjV6gHlIgSWKOOkuMlxIg/DcAHJNu7ZIEK6 +n7g== X-Gm-Message-State: AD7BkJL1usuFba1Ttts5gin9jg1xmRMxCVeXDwQMOJU4YqYlpWHxUoJ3q34q5vhCoBKCWO3KXQArNTDwnwoLG0jX+g8c1tTEadKy8jP21dNvAborxssmkE834+JhQITe8z+KTsxk6UG/sq9iJVYNAAFEUt54LSwoCcaOU1lcSrCVv3nwUtwRz4OHM0jfmqQxBNvU X-Received: by 10.25.39.6 with SMTP id n6mr2751818lfn.50.1457083274630; Fri, 04 Mar 2016 01:21:14 -0800 (PST) Received: from dell6430.guest.wifi ([91.198.246.8]) by smtp.gmail.com with ESMTPSA id r191sm437001lfe.28.2016.03.04.01.21.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Mar 2016 01:21:14 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v5 22/25] tests: hostapd.py add get_ctrl_iface_port Date: Fri, 4 Mar 2016 10:20:38 +0100 Message-Id: <1457083241-7492-23-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457083241-7492-1-git-send-email-janusz.dziedzic@tieto.com> References: <1457083241-7492-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-20160304_042137_086176_D39A0EDA X-CRM114-Status: UNSURE ( 8.56 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c04:0:0:0:22f 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 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 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")