From patchwork Wed Oct 31 08:49:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Danzberger X-Patchwork-Id: 991302 X-Patchwork-Delegate: blogic@openwrt.org 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="UdsUJBLK"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=dd-wrt.com header.i=@dd-wrt.com header.b="KRE8LiSK"; 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 42lMVb5C3Xz9s7T for ; Wed, 31 Oct 2018 19:50:31 +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:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=B5EOGseW3tVy2le4QHUg5H/SyMohSrFzaxQLQccAMVQ=; b=UdsUJBLKhvKK9c +KV14RmgHGwOqtJV7HuacFjLlgR1ecPOATFi3TqvI092QuuZnJ9HZXaZ6XBVjPOmSzU0OecMpMC+f KrhrISHqdvKlkL9uvUMEJ03BCDc/jROa1xF+QtcCA1kU0/ybB1rKfzBvg5R99ncSbBQ0pO1a1taNd Xmy6qMmm4M5VC3hmMeBVOg1BBsi3zlXKBzDDGESPxXbqIhuSIUgqQANFaHRqzqxOT3v/HC9YQDHWg sLchObnyT+lJyOmY40+edWHluUB7j4nVYXGwNmcq2nLQgrm2RrsJh497AcZCi201tgcVpCGo5OfX/ G60aa7+HjMYtW6R4Vjhw==; 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 1gHmCd-0006sc-TD; Wed, 31 Oct 2018 08:50:15 +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 1gHmCR-0005F8-D0 for openwrt-devel@lists.openwrt.org; Wed, 31 Oct 2018 08:50:06 +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:Message-Id:Date:Cc:To:From; bh=BCw+7fa9ByHFKOVadQyTjnbX/OKKuyaNJBmhKH5/doQ=; b=KRE8LiSKl3+U0Ud7EaawQfm2o6GRvWjOsz9tKzzUHqt8AbSSn2N/6n2wjBkKadSGKa6v9+1HAukwdEt/WcECjK1KzYvOvidAXPjXlula5IC84sSAPLl8wgw9nxUC/tQAQqy0BvMh03hz0DZ92tcVw0FNYFbGhHYNWWghZAk5FBk=; From: Daniel Danzberger To: openwrt-devel@lists.openwrt.org Date: Wed, 31 Oct 2018 09:49:42 +0100 Message-Id: <20181031084942.23695-1-daniel@dd-wrt.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:908:2614:35c:c1ab:1f69:2bb7:d62e 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, UPPERCASE_25_50 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: 1gHmCB-0003wL-Lh X-NMN-MailScanner: Found to be clean X-NMN-MailScanner-From: daniel@dd-wrt.com X-Received: from [2a02:908:2614:35c:c1ab:1f69:2bb7:d62e] (helo=localhost.localdomain) by webmail.newmedia-net.de with esmtpa (Exim 4.72) (envelope-from ) id 1gHmCB-0003wL-Lh; Wed, 31 Oct 2018 09:49:47 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181031_015003_781438_B86DE0E1 X-CRM114-Status: UNSURE ( 9.04 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 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_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 Subject: [OpenWrt-Devel] [PATCH] libiwinfo: nl80211: add mesh stats on assoclist. 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 --- include/iwinfo.h | 6 +++++ iwinfo_nl80211.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/include/iwinfo.h b/include/iwinfo.h index 49ee7f0..02ad623 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -126,6 +126,12 @@ struct iwinfo_assoclist_entry { uint8_t is_mfp:1; uint8_t is_tdls:1; uint32_t thr; + uint16_t llid; + uint16_t plid; + char plink_state[16]; + char local_ps[16]; + char peer_ps[16]; + char nonpeer_ps[16]; }; struct iwinfo_survey_entry { diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index ca78742..5154230 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -1756,6 +1756,57 @@ static int nl80211_get_survey_cb(struct nl_msg *msg, void *arg) return NL_SKIP; } + +static void plink_state_to_str(char *dst, unsigned state) +{ + switch (state) { + case NL80211_PLINK_LISTEN: + strcpy(dst, "LISTEN"); + break; + case NL80211_PLINK_OPN_SNT: + strcpy(dst, "OPN_SNT"); + break; + case NL80211_PLINK_OPN_RCVD: + strcpy(dst, "OPN_RCVD"); + break; + case NL80211_PLINK_CNF_RCVD: + strcpy(dst, "CNF_RCVD"); + break; + case NL80211_PLINK_ESTAB: + strcpy(dst, "ESTAB"); + break; + case NL80211_PLINK_HOLDING: + strcpy(dst, "HOLDING"); + break; + case NL80211_PLINK_BLOCKED: + strcpy(dst, "BLOCKED"); + break; + default: + strcpy(dst, "UNKNOWN"); + break; + } +} + +static void power_mode_to_str(char *dst, struct nlattr *a) +{ + enum nl80211_mesh_power_mode pm = nla_get_u32(a); + + switch (pm) { + case NL80211_MESH_POWER_ACTIVE: + strcpy(dst, "ACTIVE"); + break; + case NL80211_MESH_POWER_LIGHT_SLEEP: + strcpy(dst, "LIGHT SLEEP"); + break; + case NL80211_MESH_POWER_DEEP_SLEEP: + strcpy(dst, "DEEP SLEEP"); + break; + default: + strcpy(dst, "UNKNOWN"); + break; + } +} + static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) { struct nl80211_array_buf *arr = arg; @@ -1783,6 +1834,13 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_STA_FLAGS] = { .minlen = sizeof(struct nl80211_sta_flag_update) }, [NL80211_STA_INFO_EXPECTED_THROUGHPUT] = { .type = NLA_U32 }, + /* mesh */ + [NL80211_STA_INFO_LLID] = { .type = NLA_U16 }, + [NL80211_STA_INFO_PLID] = { .type = NLA_U16 }, + [NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 }, + [NL80211_STA_INFO_LOCAL_PM] = { .type = NLA_U32 }, + [NL80211_STA_INFO_PEER_PM] = { .type = NLA_U32 }, + [NL80211_STA_INFO_NONPEER_PM] = { .type = NLA_U32 }, }; static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = { @@ -1852,6 +1910,24 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) if (sinfo[NL80211_STA_INFO_EXPECTED_THROUGHPUT]) e->thr = nla_get_u32(sinfo[NL80211_STA_INFO_EXPECTED_THROUGHPUT]); + /* mesh */ + if (sinfo[NL80211_STA_INFO_LLID]) + e->llid = nla_get_u16(sinfo[NL80211_STA_INFO_LLID]); + + if (sinfo[NL80211_STA_INFO_PLID]) + e->plid = nla_get_u16(sinfo[NL80211_STA_INFO_PLID]); + + if (sinfo[NL80211_STA_INFO_PLINK_STATE]) + plink_state_to_str(e->plink_state, + nla_get_u8(sinfo[NL80211_STA_INFO_PLINK_STATE])); + + if (sinfo[NL80211_STA_INFO_LOCAL_PM]) + power_mode_to_str(e->local_ps, sinfo[NL80211_STA_INFO_LOCAL_PM]); + if (sinfo[NL80211_STA_INFO_PEER_PM]) + power_mode_to_str(e->peer_ps, sinfo[NL80211_STA_INFO_PEER_PM]); + if (sinfo[NL80211_STA_INFO_NONPEER_PM]) + power_mode_to_str(e->nonpeer_ps, sinfo[NL80211_STA_INFO_NONPEER_PM]); + /* Station flags */ if (sinfo[NL80211_STA_INFO_STA_FLAGS]) {