b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Simon Wunderlich <simon@open-mesh.com>
Subject: [B.A.T.M.A.N.] [PATCH] batctl: add option for multiif orig table
Date: Tue, 18 Feb 2014 15:13:24 +0100	[thread overview]
Message-ID: <1392732804-23206-1-git-send-email-sw@simonwunderlich.de> (raw)

From: Simon Wunderlich <simon@open-mesh.com>

Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
---
 debug.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/debug.c b/debug.c
index d57324d..78c6e55 100644
--- a/debug.c
+++ b/debug.c
@@ -89,8 +89,10 @@ static void debug_table_usage(int debug_table)
 	fprintf(stderr, " \t -H don't show the header\n");
 	fprintf(stderr, " \t -w [interval] watch mode - refresh the table continuously\n");
 
-	if (debug_table == BATCTL_TABLE_ORIGINATORS)
+	if (debug_table == BATCTL_TABLE_ORIGINATORS) {
 		fprintf(stderr, " \t -t timeout interval - don't print originators not seen for x.y seconds \n");
+		fprintf(stderr, " \t -i [interface] - show multiif originator table for a specific interface\n");
+	}
 }
 
 int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)
@@ -98,11 +100,12 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)
 	int optchar, read_opt = USE_BAT_HOSTS;
 	char full_path[MAX_PATH+1];
 	char *debugfs_mnt;
+	char *orig_iface = NULL;
 	float orig_timeout;
 	float watch_interval = 1;
 	opterr = 0;
 
-	while ((optchar = getopt(argc, argv, "hnw:t:H")) != -1) {
+	while ((optchar = getopt(argc, argv, "hnw:t:Hi:")) != -1) {
 		switch (optchar) {
 		case 'h':
 			debug_table_usage(debug_table);
@@ -138,11 +141,21 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)
 		case 'H':
 			read_opt |= SKIP_HEADER;
 			break;
+		case 'i':
+			if (debug_table != BATCTL_TABLE_ORIGINATORS) {
+				fprintf(stderr, "Error - unrecognised option '-%c'\n", optchar);
+				debug_table_usage(debug_table);
+				return EXIT_FAILURE;
+			}
+
+			orig_iface = optarg;
+			break;
 		case '?':
-			if (optopt == 't')
+			if (optopt == 't') {
 				fprintf(stderr, "Error - option '-t' needs a number as argument\n");
-
-			else if (optopt == 'w') {
+			} else if (optopt == 'i') {
+				fprintf(stderr, "Error - option '-i' needs an interface as argument\n");
+			} else if (optopt == 'w') {
 				read_opt |= CLR_CONT_READ;
 				break;
 			}
@@ -162,7 +175,10 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	debugfs_make_path(DEBUG_BATIF_PATH_FMT "/", mesh_iface, full_path, sizeof(full_path));
+	if (orig_iface)
+		debugfs_make_path(DEBUG_BATIF_PATH_FMT "/", orig_iface, full_path, sizeof(full_path));
+	else
+		debugfs_make_path(DEBUG_BATIF_PATH_FMT "/", mesh_iface, full_path, sizeof(full_path));
 	return read_file(full_path, (char *)batctl_debug_tables[debug_table].debugfs_name,
 			 read_opt, orig_timeout, watch_interval,
 			 batctl_debug_tables[debug_table].header_lines);
-- 
1.7.10.4


             reply	other threads:[~2014-02-18 14:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18 14:13 Simon Wunderlich [this message]
2014-02-19  7:21 ` [B.A.T.M.A.N.] [PATCH] batctl: add option for multiif orig table Marek Lindner
2014-02-19 18:18   ` Simon Wunderlich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392732804-23206-1-git-send-email-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=simon@open-mesh.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).