From patchwork Tue Jul 10 19:49:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Shmidt X-Patchwork-Id: 170270 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 5D56C2C01B4 for ; Wed, 11 Jul 2012 05:52:37 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2B9579C2E4; Tue, 10 Jul 2012 15:52:34 -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 e+2+rduzbyOB; Tue, 10 Jul 2012 15:52:33 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A06DD9C20F; Tue, 10 Jul 2012 15:52:29 -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 52E7B9C1F8 for ; Tue, 10 Jul 2012 15:52:28 -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 8vUWamliWyL0 for ; Tue, 10 Jul 2012 15:52:24 -0400 (EDT) Received: from mail-bk0-f74.google.com (mail-bk0-f74.google.com [209.85.214.74]) (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 705299C1C5 for ; Tue, 10 Jul 2012 15:52:24 -0400 (EDT) Received: by bkcjc3 with SMTP id jc3so18273bkc.5 for ; Tue, 10 Jul 2012 12:52:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:date:subject:to:message-id:x-gm-message-state; bh=KlkTt6GiiLo/wx6JY9gvX96mm/kQ+ZUFZVxPV41LAqA=; b=GxVyUw2V/+vUrOBUolfWzr9OSYXWucA8aQZk7hkj+DI7qNnwru1nZmQDeT+uVkd8+y 37qnzmmLj+d2WToT6P/14mFcztCgc2Lm49ImUd3ifOK5k/outuSiIV4trkLASx8oM02I tsPir7C3elcq7Kb02TusC9IqHerQvVvZlTbqMzAPiCqTeZXN4N8P7sqMlpWidzoxeic2 uEGfsde7JDSoUrZn12Tf66mMOSkcKst+Bn3osx+g/wKkyCcRcpabwU2N50ATH76WsRfA amwbvRN/AZ5haH0P9c9A9/8M9tdpIMlIe18QrsSdWosw2fDw092D0oWGjQ7QkOp78HLQ JKIg== Received: by 10.14.185.140 with SMTP id u12mr14918831eem.0.1341949943105; Tue, 10 Jul 2012 12:52:23 -0700 (PDT) Received: by 10.14.185.140 with SMTP id u12mr14918823eem.0.1341949942961; Tue, 10 Jul 2012 12:52:22 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id d2si1164272eei.1.2012.07.10.12.52.22 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 10 Jul 2012 12:52:22 -0700 (PDT) Received: from ushik.mtv.corp.google.com (ushik.mtv.corp.google.com [172.18.104.41]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id BFA2D20004E for ; Tue, 10 Jul 2012 12:52:22 -0700 (PDT) Received: by ushik.mtv.corp.google.com (Postfix, from userid 57417) id 197EE38371; Tue, 10 Jul 2012 12:52:21 -0700 (PDT) From: Dmitry Shmidt Date: Tue, 10 Jul 2012 12:49:30 -0700 Subject: [PATCH] Add 'get_capability channels' command To: hostap@lists.shmoo.com Message-Id: <20120710195222.197EE38371@ushik.mtv.corp.google.com> X-Gm-Message-State: ALoCoQlfGr7F1wVFnAgeFWfHXVGUNz4Nm9sDdhUvzLMTvWKLjOWC+wnULUEwEhb7+jxUbo3VB+8FhZv7G9d4pN3S1QIYCbLiGXMsAEs2F/Ve6smtgIzcYJc5TI63jUodckdgnuJTZobZaOCHGPSTeB9zntYbWXoTz4QRg9/Q33C25/bp+6e7i6lJHaeGPb57yGeAhzIhpkrkuQLyGY6TSMrFkRIP5Y5now== X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 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 Signed-off-by: Dmitry Shmidt --- wpa_supplicant/ctrl_iface.c | 48 +++++++++++++++++++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 3 +- 2 files changed, 50 insertions(+), 1 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index cb3e523..1af1f34 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2364,6 +2364,51 @@ static int ctrl_iface_get_capability_auth_alg(int res, char *strict, } +static int ctrl_iface_get_capability_channels(struct wpa_supplicant *wpa_s, + char *buf, size_t buflen) +{ + struct hostapd_channel_data *chnl; + int ret, i, j; + char *pos, *end, *hmode; + + pos = buf; + end = pos + buflen; + + for (j = 0; j < wpa_s->hw.num_modes; j++) { + switch (wpa_s->hw.modes[j].mode) { + case HOSTAPD_MODE_IEEE80211B: + hmode = "B"; + break; + case HOSTAPD_MODE_IEEE80211G: + hmode = "G"; + break; + case HOSTAPD_MODE_IEEE80211A: + hmode = "A"; + break; + default: + return pos - buf; + } + ret = os_snprintf(pos, end - pos, "Mode[%s] Channels:", hmode); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + chnl = wpa_s->hw.modes[j].channels; + for (i = 0; i < wpa_s->hw.modes[j].num_channels; i++) { + ret = os_snprintf(pos, end - pos, " %d", chnl[i].chan); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + } + ret = os_snprintf(pos, end - pos, "\n"); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + } + + return pos - buf; +} + + static int wpa_supplicant_ctrl_iface_get_capability( struct wpa_supplicant *wpa_s, const char *_field, char *buf, size_t buflen) @@ -2414,6 +2459,9 @@ static int wpa_supplicant_ctrl_iface_get_capability( return ctrl_iface_get_capability_auth_alg(res, strict, &capa, buf, buflen); + if (os_strcmp(field, "channels") == 0) + return ctrl_iface_get_capability_channels(wpa_s, buf, buflen); + wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown GET_CAPABILITY field '%s'", field); diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index b159ad3..d1e7723 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -3087,7 +3087,8 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { "< | > = get detailed scan result info" }, { "get_capability", wpa_cli_cmd_get_capability, cli_cmd_flag_none, - " = get capabilies" }, + "\n" + " = get capabilies" }, { "reconfigure", wpa_cli_cmd_reconfigure, cli_cmd_flag_none, "= force wpa_supplicant to re-read its configuration file" },