From patchwork Mon Feb 18 21:35:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Danzberger X-Patchwork-Id: 1044343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=dd-wrt.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AzApzy8M"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=dd-wrt.com header.i=@dd-wrt.com header.b="H97RbNj3"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 443HGd5Jdlz9s1l for ; Tue, 19 Feb 2019 08:35:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wW/J5BpNeIs6pmjMtrbJJRvF7RUENMCl3quXRKkEmm4=; b=AzApzy8MAPKoId s2vZvVwUG+JTv9LehjbuDVTH08frsVgHX+tQMazR5PfV+OZQnjKLR+iXLvBALyGKWqMVW8Altc56N xh1lF6XZp6252XJ6QS8CivFd7PTRbTW5nXdJmlheDAP6TNio20KKAo4StR6gZqd5yxy+Hh4NXgINd zp4mVUl1CgCY/HJRjSCCY9dtqzLLWIObmxEhxsPhzO0Qug0O5be/bSAlVaQxFX7X6MU95UVBcZeIO DgkoPmj5+XZbzaZMZcl2400PfVAjye3tUJsUXsV2KpZz9VdXDBS27DyzS093k2j5ckx0+nSmT/X05 SNKKuZbjX3QLI5vIuGGw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvqZM-0003sl-5W; Mon, 18 Feb 2019 21:35:20 +0000 Received: from smtps.newmedia-net.de ([2a05:a1c0:0:de::167] helo=webmail.newmedia-net.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvqZI-0003ry-Dy for openwrt-devel@lists.openwrt.org; Mon, 18 Feb 2019 21:35:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dd-wrt.com; s=mikd; h=Subject:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Cc:To:From; bh=zgFrndmHQC69STisUKFE6gGj7MSVQdawSBkGZp7KkXM=; b=H97RbNj3yirCzWes5BkkNpwQDIu2DiH8kv0Zo+PkRcmxf+OI9SVV5XHqhhRoHd+x1SHexGqNyWXL3qdVPBlkNSCQAM2D9aZR/FMSyGQpDABuSC+bu6O2ygdFoZwEwZyo4jrb8Wp6/VpzDgD2xzOnPsOvV6zJaAzQD5wMkXVZi04=; From: Daniel Danzberger To: openwrt-devel@lists.openwrt.org Date: Mon, 18 Feb 2019 22:35:06 +0100 Message-Id: <20190218213507.12204-2-daniel@dd-wrt.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218213507.12204-1-daniel@dd-wrt.com> References: <20190218213507.12204-1-daniel@dd-wrt.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:908:261a:4fbc:5885:4b04:a1b4:98b5 X-SA-Exim-Mail-From: daniel@dd-wrt.com X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on webmail.newmedia-net.de X-Spam-Level: X-Spam-Status: No, score=-2.6 required=4.0 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.1.9, No X-SA-Exim-Version: 4.2.1 (built Thu, 26 May 2011 15:22:33 +0200) X-SA-Exim-Scanned: Yes (on webmail.newmedia-net.de) X-NMN-MailScanner-Information: Please contact the ISP for more information X-NMN-MailScanner-ID: 1gvqZG-00051T-Ty X-NMN-MailScanner: Found to be clean X-NMN-MailScanner-From: daniel@dd-wrt.com X-Received: from [2a02:908:261a:4fbc:5885:4b04:a1b4:98b5] (helo=localhost.localdomain) by webmail.newmedia-net.de with esmtpa (Exim 4.72) (envelope-from ) id 1gvqZG-00051T-Ty; Mon, 18 Feb 2019 22:35:15 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190218_133516_911642_52FDC99A X-CRM114-Status: UNSURE ( 7.65 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH 2/3][rpcd] iwinfo: add survey. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Danzberger Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Daniel Danzberger --- iwinfo.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/iwinfo.c b/iwinfo.c index d476ce3..983001a 100644 --- a/iwinfo.c +++ b/iwinfo.c @@ -511,6 +511,45 @@ rpc_iwinfo_assoclist(struct ubus_context *ctx, struct ubus_object *obj, return UBUS_STATUS_OK; } +static int +rpc_iwinfo_survey(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + char res[IWINFO_BUFSIZE]; + struct iwinfo_survey_entry *e; + void *c, *d; + int i, rv, len; + + blob_buf_init(&buf, 0); + + rv = rpc_iwinfo_open(msg); + + c = blobmsg_open_array(&buf, "results"); + + if (rv || iw->survey(ifname, res, &len) || len < 0) + return UBUS_STATUS_OK; + + for (i = 0; i < len; i += sizeof(struct iwinfo_survey_entry)) { + e = (struct iwinfo_survey_entry *)&res[i]; + + d = blobmsg_open_table(&buf, NULL); + blobmsg_add_u32(&buf, "mhz", e->mhz); + blobmsg_add_u32(&buf, "noise", e->noise); + blobmsg_add_u64(&buf, "active_time", e->active_time); + blobmsg_add_u64(&buf, "busy_time", e->busy_time); + blobmsg_add_u64(&buf, "busy_time_ext", e->busy_time_ext); + blobmsg_add_u64(&buf, "rx_time", e->rxtime); + blobmsg_add_u64(&buf, "tx_time", e->txtime); + blobmsg_close_table(&buf, d); + } + + blobmsg_close_array(&buf, c); + ubus_send_reply(ctx, req, buf.head); + rpc_iwinfo_close(); + return UBUS_STATUS_OK; +} + static int rpc_iwinfo_freqlist(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, @@ -791,6 +830,7 @@ rpc_iwinfo_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx) UBUS_METHOD("freqlist", rpc_iwinfo_freqlist, rpc_device_policy), UBUS_METHOD("txpowerlist", rpc_iwinfo_txpowerlist, rpc_device_policy), UBUS_METHOD("countrylist", rpc_iwinfo_countrylist, rpc_device_policy), + UBUS_METHOD("survey", rpc_iwinfo_survey, rpc_device_policy), UBUS_METHOD("phyname", rpc_iwinfo_phyname, rpc_uci_policy), };