From patchwork Fri Feb 26 09:38:24 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: 588710 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 12850140271 for ; Fri, 26 Feb 2016 20:39:49 +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=pdr1w+mZ; 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 1aZEs9-0004Hd-K0; Fri, 26 Feb 2016 09:39:41 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZEry-00048J-RW for hostap@lists.infradead.org; Fri, 26 Feb 2016 09:39:32 +0000 Received: by mail-wm0-x22b.google.com with SMTP id g62so65127783wme.0 for ; Fri, 26 Feb 2016 01:39:10 -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=pdr1w+mZCBg9D20Zx/x4aeZNfoUVPqsaWMuDh5/x3uyKIvzREgljnSaUHvlkNB164e gLJU5WvFzlT1rl7dog3lfdHnboABjLiKfz83xUio23HtHK19d3GkuTwhfC2K7F+J8Y7e jfhX1+NlwW/+cSMCgkrc1TIYj3N7z/s9/wSc8= 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=cjirb8v0CBizY+E3pG2xdzS1/yL3oOF97X8wliE8buPRlUMx9PCqwPyAQYfUcPAH23 u36zSOY72O+VwKLvV0QZEuDEvitGQ+yoZi1ugxT9/wlOxYo74H7mdC3b4SCahdL6KBoG mD0S5CgTn1/QAnm38rVhWyBKIhkEIVYqNTELrhJzBsTtzr8bMCCHOA0fOP7PiBADwFwO kj76TNRLOI4iPyHu6JGmAD01XlxyttCKtdyO/huKvwK5pdQyzz4ezkZ8fVRicpg9Ol7d OrCn0hzzFAO60wrQVyBSeHI6WTOe6Z87twapDHqD6fpg4CDAL4cAyJIHG8yaXY96PC8B 7j1w== X-Gm-Message-State: AD7BkJKBK5AODXz0qDp1OjwmKNI8qPRAAB4Zz8jeHRp1jz9YYXaxShCfRBWe9FdWYN9oZXH+p10kWYtOPw/nn8QZaZqKblfeofxMs+eqhCIey7LXxp9toBlwsxY43GJqB7942FVxzM3xsFzcowLGfqeaZ/KJ7m0rTgGLSXrMdzIhwfphwdvf08wQ0JWjB7iz8dXg X-Received: by 10.194.112.34 with SMTP id in2mr718938wjb.160.1456479549346; Fri, 26 Feb 2016 01:39:09 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 01:39:08 -0800 (PST) From: Janusz Dziedzic To: hostap@lists.infradead.org Subject: [PATCH v4 09/29] hostapd: ctrl udp allow to set port Date: Fri, 26 Feb 2016 10:38:24 +0100 Message-Id: <1456479524-14185-10-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_013931_237023_D5F5D6D9 X-CRM114-Status: GOOD ( 11.92 ) 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 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 "