From patchwork Sun Jul 3 11:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16460 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id B38078249A; Sun, 3 Jul 2016 13:35:44 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=tZwqptKe; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id 07D3D82459 for ; Sun, 3 Jul 2016 13:35:18 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C964F90000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c9:64f9::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 71B021100F1 for ; Sun, 3 Jul 2016 13:35:18 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1467545718; bh=dxnSM8+3hDukilVdoXQZ5r4gQoO60RElp1dOUyxFRgQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tZwqptKe2mTxesGuOXFk1rLJxRSJ/12JTtSb23QE5OJOyzMfyRB/8i0pB0s+521fy ntQZCWKPqWIJs9cwiR3fDh4+8wMCKGgLJqqNWZnACd2Q4X4UsduimqZJK4qY3+l0yl oUxRxXe+mpRSCwxFCuEo8vpZwWQwVvUpxtkZljTU= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 3 Jul 2016 13:35:09 +0200 Message-Id: <1467545714-20722-4-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1467545714-20722-1-git-send-email-sven@narfation.org> References: <1467545714-20722-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH v10 3/8] batctl: add netlink dump support for B.A.T.M.A.N. V gateways X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" Signed-off-by: Sven Eckelmann --- netlink.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/netlink.c b/netlink.c index bb543ca..9dff93a 100644 --- a/netlink.c +++ b/netlink.c @@ -789,7 +789,6 @@ static int translocal_callback(struct nl_msg *msg, void *arg) static const int gateways_mandatory[] = { BATADV_ATTR_ORIG_ADDRESS, - BATADV_ATTR_TQ, BATADV_ATTR_ROUTER, BATADV_ATTR_HARD_IFNAME, BATADV_ATTR_BANDWIDTH_DOWN, @@ -806,6 +805,7 @@ static int gateways_callback(struct nl_msg *msg, void *arg) const char *primary_if; uint32_t bandwidth_down; uint32_t bandwidth_up; + uint32_t throughput; uint8_t *router; uint8_t *orig; char c = ' '; @@ -837,7 +837,6 @@ static int gateways_callback(struct nl_msg *msg, void *arg) c = '*'; orig = nla_data(attrs[BATADV_ATTR_ORIG_ADDRESS]); - tq = nla_get_u8(attrs[BATADV_ATTR_TQ]); router = nla_data(attrs[BATADV_ATTR_ROUTER]); primary_if = nla_get_string(attrs[BATADV_ATTR_HARD_IFNAME]); bandwidth_down = nla_get_u32(attrs[BATADV_ATTR_BANDWIDTH_DOWN]); @@ -853,7 +852,13 @@ static int gateways_callback(struct nl_msg *msg, void *arg) else printf("%17s ", bat_host->name); - printf("(%3i) ", tq); + if (attrs[BATADV_ATTR_THROUGHPUT]) { + throughput = nla_get_u32(attrs[BATADV_ATTR_THROUGHPUT]); + printf("(%9u.%1u) ", throughput / 10, throughput % 10); + } else if (attrs[BATADV_ATTR_TQ]) { + tq = nla_get_u8(attrs[BATADV_ATTR_TQ]); + printf("(%3i) ", tq); + } bat_host = bat_hosts_find_by_mac((char *)router); if (!(opts->read_opt & USE_BAT_HOSTS) || !bat_host) @@ -1163,10 +1168,31 @@ int netlink_print_translocal(char *mesh_iface, char *orig_iface, int read_opts, int netlink_print_gateways(char *mesh_iface, char *orig_iface, int read_opts, float orig_timeout, float watch_interval) -{ +{ char *header; + int ifindex; + + ifindex = if_nametoindex(mesh_iface); + if (!ifindex) { + fprintf(stderr, "Interface %s is unknown\n", mesh_iface); + return -ENODEV; + } + + netlink_print_info(ifindex, BATADV_CMD_GET_ORIGINATORS, PARSE_ONLY); + + if (strlen(algo_name_buf) == 0) + return -EINVAL; + + if (!strcmp("BATMAN_IV", algo_name_buf)) + header = " Router ( TQ) Next Hop [outgoingIf] Bandwidth\n"; + if (!strcmp("BATMAN_V", algo_name_buf)) + header = " Router ( throughput) Next Hop [outgoingIf] Bandwidth\n"; + + if (!header) + return -EINVAL; + return netlink_print_common(mesh_iface, orig_iface, read_opts, orig_timeout, watch_interval, - " Router TQ Next Hop outgoingIf Bandwidth\n", + header, BATADV_CMD_GET_GATEWAYS, gateways_callback); }