From patchwork Fri Mar 4 09:20:25 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: 591846 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 7F104140BBA for ; Fri, 4 Mar 2016 20:21:39 +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=ISb8dC17; 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 1ablvQ-0001wq-Bl; Fri, 04 Mar 2016 09:21:32 +0000 Received: from mail-lb0-x22d.google.com ([2a00:1450:4010:c04::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ablvH-0001mL-2i for hostap@lists.infradead.org; Fri, 04 Mar 2016 09:21:25 +0000 Received: by mail-lb0-x22d.google.com with SMTP id k15so54120824lbg.0 for ; Fri, 04 Mar 2016 01:21:02 -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=/n3q/ojtlJhNcmsLOZK7c+6YGUai7rF7sgDNjSh4ohc=; b=ISb8dC1735X+tm8Y9oCffU3Ol/Up3w3q2j/KPB4wpEiXepzx48H4plnkJ3cAJD5CuK Sd2NjX3GIZDr/5iiIx0umueER1hst+BsOr4qdMOsQTkBXTm1ptXRXsoHx4ZdTPR5rezU oiVXySgsqVCUfGF9i8ev28oV1dFWCs0Zuu6M8= 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=/n3q/ojtlJhNcmsLOZK7c+6YGUai7rF7sgDNjSh4ohc=; b=caBBkI/VYk7pD77s39YrFby6B2xd4xiPVlTdgsx1pZ8C1g/NvVxHDcoYjOQEqdx8Cd gMcc9oecQszSvGeOGRQVLsfpFRjTk5Nx/qcN7oTOOMR+x2xGj+S0e9FVsUBIdycO/yBP Lcdqe3MBLx9wLjCQ0ewa//v9fzt82cBac/cxgBHEVLuV2wJxG7VSgU1vnOPgAuTVyMDd 04hTF4mBawIJlrPbEd9MJ/oZz+6fKMXuRcZzblC7k99q5p4UnzNK/sINgNqzjeMWTOSf Svignz5p2xrtX0OUTOWYtPgv9jSXzmh2nMZuQialKlzcVyZNkQi3cCzGrC2ID5aKh1g2 txFw== X-Gm-Message-State: AD7BkJK92o/CrmPiQMZe205ceix3YVsQ+o2GFtafuUtfsBOf4CvL1ssy3s1Ok+ML//PUMu68iJocGjoZHWilZsFPe5Imh9i4+0dsohOCldLofBkktnX0OKQSL15uAreVQy1N0/IL3ovOnyUHUYHWhf0Qdp838E3XtagAoTjqZ81evpSYtUvg6s0M41sIlki6ixZy X-Received: by 10.112.184.133 with SMTP id eu5mr2031519lbc.99.1457083261325; Fri, 04 Mar 2016 01:21:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Mar 2016 01:21:00 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v5 09/25] hostapd: ctrl udp allow to set port Date: Fri, 4 Mar 2016 10:20:25 +0100 Message-Id: <1457083241-7492-10-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_012123_452168_BC9A851C X-CRM114-Status: GOOD ( 12.15 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.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:22d 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 Allow to setup port for ctrl and globa UDP iface. The format is: udp: eg. wpa_supplicant -Dnl80211 -ddt -g udp:8888 or in conf file ctrl_interface=udp:8877 Signed-off-by: Janusz Dziedzic --- hostapd/ctrl_iface.c | 28 ++++++++++++++++++++++++++-- hostapd/main.c | 5 +++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 89aad34..c419426 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -2446,6 +2446,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd) { int port = HOSTAPD_CTRL_IFACE_PORT; char p[32]={0}; + char *pos; struct addrinfo hints = { 0 }, *res, *saveres; int n; @@ -2457,6 +2458,16 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd) if (hapd->conf->ctrl_interface == NULL) return 0; + pos = os_strstr(hapd->conf->ctrl_interface, "udp:"); + if (pos) { + pos += 4; + port = atoi(pos); + if (!port) { + wpa_printf(MSG_ERROR, "invalid ctrl udp port"); + goto fail; + } + } + dl_list_init(&hapd->ctrl_dst); hapd->ctrl_sock = -1; os_get_random(cookie, COOKIE_LEN); @@ -2489,7 +2500,8 @@ try_again: if (bind(hapd->ctrl_sock, res->ai_addr, res->ai_addrlen) < 0) { port--; - if ((HOSTAPD_CTRL_IFACE_PORT - port) < HOSTAPD_CTRL_IFACE_PORT_LIMIT) + if ((HOSTAPD_CTRL_IFACE_PORT - port) < HOSTAPD_CTRL_IFACE_PORT_LIMIT && + !pos) goto try_again; wpa_printf(MSG_ERROR, "bind(AF_INET): %s", strerror(errno)); goto fail; @@ -3163,6 +3175,7 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface) { int port = HOSTAPD_GLOBAL_CTRL_IFACE_PORT; char p[32]={0}; + char *pos; struct addrinfo hints = { 0 }, *res, *saveres; int n; @@ -3174,6 +3187,16 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface) if (interface->global_iface_path == NULL) return 0; + pos = os_strstr(interface->global_iface_path, "udp:"); + if (pos) { + pos += 4; + port = atoi(pos); + if (!port) { + wpa_printf(MSG_ERROR, "invalid global ctrl udp port"); + goto fail; + } + } + dl_list_init(&interface->global_ctrl_dst); interface->global_ctrl_sock = -1; os_get_random(gcookie, COOKIE_LEN); @@ -3206,7 +3229,8 @@ try_again: if (bind(interface->global_ctrl_sock, res->ai_addr, res->ai_addrlen) < 0) { port++; - if ((port - HOSTAPD_GLOBAL_CTRL_IFACE_PORT) < HOSTAPD_GLOBAL_CTRL_IFACE_PORT_LIMIT) + if ((port - HOSTAPD_GLOBAL_CTRL_IFACE_PORT) < HOSTAPD_GLOBAL_CTRL_IFACE_PORT_LIMIT && + !pos) goto try_again; wpa_printf(MSG_ERROR, "bind(AF_INET): %s", strerror(errno)); goto fail; diff --git a/hostapd/main.c b/hostapd/main.c index 6c4e195..47df24d 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -489,6 +489,11 @@ static int hostapd_get_global_ctrl_iface(struct hapd_interfaces *interfaces, interfaces->global_iface_path = os_strdup(path); if (interfaces->global_iface_path == NULL) return -1; + +#ifdef CONFIG_CTRL_IFACE_UDP + return 0; +#endif + pos = os_strrchr(interfaces->global_iface_path, '/'); if (pos == NULL) { wpa_printf(MSG_ERROR, "No '/' in the global control interface "