From patchwork Wed Jun 10 22:17:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 6585411 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 564309F326 for ; Wed, 10 Jun 2015 22:18:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 79B2720220 for ; Wed, 10 Jun 2015 22:18:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94EAD2039C for ; Wed, 10 Jun 2015 22:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754095AbbFJWST (ORCPT ); Wed, 10 Jun 2015 18:18:19 -0400 Received: from mail2.candelatech.com ([208.74.158.173]:41187 "EHLO mail2.candelatech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751767AbbFJWSR (ORCPT ); Wed, 10 Jun 2015 18:18:17 -0400 Received: from localhost.localdomain (unknown [50.251.239.81]) by mail2.candelatech.com (Postfix) with ESMTP id 767E240A79A; Wed, 10 Jun 2015 15:18:17 -0700 (PDT) From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Ben Greear Subject: [PATCH] iw: Use ifname if available, print new/del/stop events. Date: Wed, 10 Jun 2015 18:17:55 -0400 Message-Id: <1433974675-19225-1-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 1.9.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Greear If the kernel sends the IFNAME in the netlink message, then use it to save the call to map ifindex to name (and potentially fix races, especially when kernel is busy deleting an interface. Signed-off-by: Ben Greear --- event.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/event.c b/event.c index 929854b..b87a076 100644 --- a/event.c +++ b/event.c @@ -317,15 +317,22 @@ static int print_event(struct nl_msg *msg, void *arg) nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL); - if (tb[NL80211_ATTR_IFINDEX] && tb[NL80211_ATTR_WIPHY]) { + ifname[0] = 0; + if (tb[NL80211_ATTR_IFNAME]) { + memset(ifname, 0, sizeof(ifname)); + strncpy(ifname, nla_data(tb[NL80211_ATTR_IFNAME]), IFNAMSIZ); + } + else if (tb[NL80211_ATTR_IFINDEX]) { if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname); + } + + if (ifname[0] && tb[NL80211_ATTR_WIPHY]) { printf("%s (phy #%d): ", ifname, nla_get_u32(tb[NL80211_ATTR_WIPHY])); } else if (tb[NL80211_ATTR_WDEV] && tb[NL80211_ATTR_WIPHY]) { printf("wdev 0x%llx (phy #%d): ", (unsigned long long)nla_get_u64(tb[NL80211_ATTR_WDEV]), nla_get_u32(tb[NL80211_ATTR_WIPHY])); - } else if (tb[NL80211_ATTR_IFINDEX]) { - if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname); + } else if (ifname[0]) { printf("%s: ", ifname); } else if (tb[NL80211_ATTR_WDEV]) { printf("wdev 0x%llx: ", (unsigned long long)nla_get_u64(tb[NL80211_ATTR_WDEV])); @@ -599,6 +606,15 @@ static int print_event(struct nl_msg *msg, void *arg) } printf("\n"); break; + case NL80211_CMD_STOP_AP: + printf("stop AP\n"); + break; + case NL80211_CMD_NEW_INTERFACE: + printf("new interface\n"); + break; + case NL80211_CMD_DEL_INTERFACE: + printf("delete interface\n"); + break; default: printf("unknown event %d (%s)\n", gnlh->cmd, command_name(gnlh->cmd));