From patchwork Tue May 14 22:50:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Shmidt X-Patchwork-Id: 243854 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C6FEC2C0091 for ; Wed, 15 May 2013 08:52:41 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 73BBA9C193; Tue, 14 May 2013 18:52:38 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X1PVVel+bkpI; Tue, 14 May 2013 18:52:38 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B790F9C196; Tue, 14 May 2013 18:52:33 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id BE6BD9C196 for ; Tue, 14 May 2013 18:52:31 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ULqVuOCS6yUC for ; Tue, 14 May 2013 18:52:26 -0400 (EDT) Received: from mail-gg0-f202.google.com (mail-gg0-f202.google.com [209.85.161.202]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id A3B6F9C1C0 for ; Tue, 14 May 2013 18:52:07 -0400 (EDT) Received: by mail-gg0-f202.google.com with SMTP id 4so127038ggm.1 for ; Tue, 14 May 2013 15:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:date:subject:to:message-id; bh=b73/SPwmnlP3onhpWzn7dtG8AlPHHMBHONzbHg+b9Lw=; b=EFhwkrwMw5Ayb01ZMIYXa4KugDdj4jXtpVupkdhiYOt0kAPor3wMQRZu/hTNsxHRRH GaGTQcU4dKv8n/QBD43P8++RMR2E7TAMhYAZ+R6sAJieW++kd8Qz2LwH3qvYfzU/t9m9 1K0VSt4MPdhu7sFqPAO/5EdUie97rYhJHDNVpbQSm9aWRGdnxm0r7nNyVNRL18EaSdq/ ylS0PgUkzBCsxexp2YaPE9tDjhgvg/c0HY9DtWrxNAHNOHuJ/NjYqnG2E11K4pSR5BWH egjGv87VIxdXJryrDIuQQQ+4e0NV4BgP311af11KM60MTewgXOQStp6fzidLDkfmUnhZ f6WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:date:subject:to:message-id:x-gm-message-state; bh=b73/SPwmnlP3onhpWzn7dtG8AlPHHMBHONzbHg+b9Lw=; b=XiuYuwr8l43iA6CigDFtw3Zzfu+w/sEtbImRzM2LP7oRtm7alP5Tr2PaATRzImbOTn b5kgNdp0adU9RxvYGq2NVziBfYRGUQHWAwgTrwUBvL1Uy5hZoYLWdT8/OwkEuvrbqRka 57F6GFMY6UBOLeH51WaYCBsgBOuHgZDOMMTjZZ6WubhyW3yQRgGN8D3jlx0c3GSF8vHd +ZsZUGqTqlkaAELWwaQy2ARsepFSnL+CLqjvFjkjFxutFiakwvkKLj1wfDlu011CFze2 76FCyJ51Ug2EIJtGZhBEoruGRhjk9+pQCcUp5og88gIAT5slsB5nyKZvE5o4xNoJ0w2X jGww== X-Received: by 10.236.141.37 with SMTP id f25mr7803488yhj.50.1368571927176; Tue, 14 May 2013 15:52:07 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id h2si21213yhj.2.2013.05.14.15.52.07 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2013 15:52:07 -0700 (PDT) Received: from ushik.mtv.corp.google.com (ushik.mtv.corp.google.com [172.18.104.41]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 0BDF831C08F for ; Tue, 14 May 2013 15:52:07 -0700 (PDT) Received: by ushik.mtv.corp.google.com (Postfix, from userid 57417) id 9F82B13FD78; Tue, 14 May 2013 15:52:06 -0700 (PDT) From: Dmitry Shmidt Date: Tue, 14 May 2013 15:50:10 -0700 Subject: [PATCH] P2P: Add IFNAME=iface command option for interface redirection To: hostap@lists.shmoo.com Message-Id: <20130514225206.9F82B13FD78@ushik.mtv.corp.google.com> X-Gm-Message-State: ALoCoQnYc1eTj+8Xq376ZlRL4tQg8p/uaWsaJHWqs1H8nT04WtV0al8MMl9+GH2MlKJxmwIZ9r5q+BnGTdX7FmptzYENuROf4MmrYP3+/E+ejBVmnvKVYsMyce04idLnBQZavBCzG7Li3yjO0WIxyXtLvKJOHaYSz3ET8/fnBUg5m2mlqmpj/orbzqmk62O4PejNPy5Fc5mElNtMRv6m1M43MhdMPL2Nze5xplgG9DwHNgdCmKvBpfc= X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Change-Id: I8b7d42b52897eee014457ff1ee8c3d12d14e1b20 Signed-off-by: Dmitry Shmidt --- wpa_supplicant/ctrl_iface.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a7d5965..9ef9ae6 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -5188,6 +5188,41 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s) } +/* + * Expected command format: CMD IFNAME=ifname [rest of command] + */ +struct wpa_supplicant *wpa_supplicant_redir_iface(struct wpa_supplicant *wpa_s, + char *buf) +{ + struct wpa_supplicant *wpa_r = wpa_s; +#ifdef CONFIG_P2P + char *ifname, *ifend; + + ifname = os_strstr(buf, "IFNAME="); + if (ifname != NULL) { + ifend = os_strchr(ifname + 7, ' '); + if (ifend != NULL) + *ifend++ = '\0'; + else + *(ifname - 1) = '\0'; + for (wpa_r=wpa_s->global->ifaces; wpa_r; wpa_r=wpa_r->next) { + if (os_strcmp(wpa_r->ifname, ifname + 7) == 0) + break; + } + if (wpa_r == NULL) { + wpa_printf(MSG_ERROR, "P2P: %s doesn't exist", + ifname + 7); + wpa_r = wpa_s; + } + if (ifend != NULL) + os_memmove(ifname, ifend, os_strlen(ifend) + 1); + wpa_printf(MSG_DEBUG, "%s %s", wpa_r->ifname, buf); + } +#endif + return wpa_r; +} + + char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, char *buf, size_t *resp_len) { @@ -5196,6 +5231,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, int ctrl_rsp = 0; int reply_len; + wpa_s = wpa_supplicant_redir_iface(wpa_s, buf); + if (os_strncmp(buf, WPA_CTRL_RSP, os_strlen(WPA_CTRL_RSP)) == 0 || os_strncmp(buf, "SET_NETWORK ", 12) == 0 || os_strncmp(buf, "WPS_NFC_TAG_READ", 16) == 0 ||