From patchwork Thu Oct 25 16:22:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17555 X-Patchwork-Delegate: sw@simonwunderlich.de 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 5D951830E1; Thu, 25 Oct 2018 18:22:59 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="I3+1Z7PR"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 9F480830AF for ; Thu, 25 Oct 2018 18:22:56 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593D355EE7FED32DEE9F3DCBB.dip0.t-ipconnect.de [IPv6:2003:c5:93d3:55ee:7fed:32de:e9f3:dcbb]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 200761100DE; Thu, 25 Oct 2018 18:22:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1540484576; bh=ObhvKVgqfGnZA9os8WOfBvYjfIL6Ql8YuFk6d5rd2NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I3+1Z7PR1ToC0qMPqNhCXlKf6NeDzSjD3wl5qp8ojyWrASJw7zh2H4gfmD6ASjgpY LBLSqnS/shBH1jdwwcb9uTnsllmzgVwFpY6TWRMUROhze9i7BRlYGQg5Fc6UYrOZyE KnY+jZ3CiGvBLLqz29HQKB+/WIivdHZ0dEBoev6I= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 25 Oct 2018 18:22:05 +0200 Message-Id: <20181025162245.19389-3-sven@narfation.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181025162245.19389-1-sven@narfation.org> References: <20181025162245.19389-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH v3 02/42] batctl: Use common code organization for statistics X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 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" Most commands have a separate file which is called like command itself. They also tend to share the same function signature to make it easier to use. Do the same for the ethtool statistics to make it easier to find. Signed-off-by: Sven Eckelmann --- Makefile | 2 +- main.c | 4 ++-- ioctl.c => statistics.c | 6 ++++-- ioctl.h => statistics.h | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) rename ioctl.c => statistics.c (95%) rename ioctl.h => statistics.h (88%) diff --git a/Makefile b/Makefile index 4b417d5..6f620be 100755 --- a/Makefile +++ b/Makefile @@ -34,10 +34,10 @@ OBJ += genl.o OBJ += hash.o OBJ += icmp_helper.o OBJ += interface.o -OBJ += ioctl.o OBJ += main.o OBJ += netlink.o OBJ += ping.o +OBJ += statistics.o OBJ += sys.o OBJ += tcpdump.o OBJ += tp_meter.o diff --git a/main.c b/main.c index d5504e0..e904a1f 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,7 @@ #include "tcpdump.h" #include "tp_meter.h" #include "bisect_iv.h" -#include "ioctl.h" +#include "statistics.h" #include "functions.h" char mesh_dfl_iface[] = "bat0"; @@ -187,7 +187,7 @@ int main(int argc, char **argv) } else if ((strcmp(argv[1], "statistics") == 0) || (strcmp(argv[1], "s") == 0)) { - ret = ioctl_statistics_get(mesh_iface); + ret = statistics(mesh_iface, argc - 1, argv + 1); } else if ((strcmp(argv[1], "translate") == 0) || (strcmp(argv[1], "t") == 0)) { diff --git a/ioctl.c b/statistics.c similarity index 95% rename from ioctl.c rename to statistics.c index 6f9a056..8a889ca 100644 --- a/ioctl.c +++ b/statistics.c @@ -34,7 +34,8 @@ #include #include -#include "ioctl.h" +#include "main.h" +#include "statistics.h" void check_root_or_die(const char *cmd); @@ -102,7 +103,8 @@ static int statistics_custom_get(int fd, struct ifreq *ifr) return ret; } -int ioctl_statistics_get(char *mesh_iface) +int statistics(char *mesh_iface, int argc __maybe_unused, + char **argv __maybe_unused) { struct ifreq ifr; int fd = -1, ret = EXIT_FAILURE; diff --git a/ioctl.h b/statistics.h similarity index 88% rename from ioctl.h rename to statistics.h index 1b216c0..3737a48 100644 --- a/ioctl.h +++ b/statistics.h @@ -20,9 +20,9 @@ * License-Filename: LICENSES/preferred/GPL-2.0 */ -#ifndef _BATCTL_IOCTL_H -#define _BATCTL_IOCTL_H +#ifndef _BATCTL_STATISTICS_H +#define _BATCTL_STATISTICS_H -int ioctl_statistics_get(char *mesh_iface); +int statistics(char *mesh_iface, int argc, char **argv); #endif