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 <sven@narfation.org>
---
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%)
@@ -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
@@ -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)) {
similarity index 95%
rename from ioctl.c
rename to statistics.c
@@ -34,7 +34,8 @@
#include <linux/ethtool.h>
#include <stdint.h>
-#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;
similarity index 88%
rename from ioctl.h
rename to 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