From: Marek Lindner <lindner_marek@yahoo.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <lindner_marek@yahoo.de>
Subject: [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - add option to select all packet types except specified
Date: Sun, 29 May 2011 19:17:40 +0200 [thread overview]
Message-ID: <1306689460-30162-2-git-send-email-lindner_marek@yahoo.de> (raw)
In-Reply-To: <1306689460-30162-1-git-send-email-lindner_marek@yahoo.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
tcpdump.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/tcpdump.c b/tcpdump.c
index 6f1adc1..3e68844 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -51,8 +51,9 @@ if ((size_t)(buff_len) < (check_len)) { \
return; \
}
-static unsigned short dump_level = DUMP_TYPE_BATOGM | DUMP_TYPE_BATICMP | DUMP_TYPE_BATUCAST |
+static unsigned short dump_level_all = DUMP_TYPE_BATOGM | DUMP_TYPE_BATICMP | DUMP_TYPE_BATUCAST |
DUMP_TYPE_BATBCAST | DUMP_TYPE_BATVIS | DUMP_TYPE_BATFRAG | DUMP_TYPE_BATTT | DUMP_TYPE_NONBAT;
+static unsigned short dump_level;
static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed);
@@ -63,6 +64,8 @@ static void tcpdump_usage(void)
printf(" \t -h print this help\n");
printf(" \t -n don't convert addresses to bat-host names\n");
printf(" \t -p dump specific packet type\n");
+ printf(" \t -x dump all packet types except specified\n");
+ printf("packet types:\n");
printf(" \t\t%3d - batman ogm packets\n", DUMP_TYPE_BATOGM);
printf(" \t\t%3d - batman icmp packets\n", DUMP_TYPE_BATICMP);
printf(" \t\t%3d - batman unicast packets\n", DUMP_TYPE_BATUCAST);
@@ -621,7 +624,9 @@ int tcpdump(int argc, char **argv)
unsigned char packet_buff[2000];
int monitor_header_len = -1;
- while ((optchar = getopt(argc, argv, "hnp:")) != -1) {
+ dump_level = dump_level_all;
+
+ while ((optchar = getopt(argc, argv, "hnp:x:")) != -1) {
switch (optchar) {
case 'h':
tcpdump_usage();
@@ -632,10 +637,16 @@ int tcpdump(int argc, char **argv)
break;
case 'p':
tmp = strtol(optarg, NULL , 10);
- if ((tmp > 0) && (tmp <= dump_level))
+ if ((tmp > 0) && (tmp <= dump_level_all))
dump_level = tmp;
found_args += ((*((char*)(optarg - 1)) == optchar ) ? 1 : 2);
break;
+ case 'x':
+ tmp = strtol(optarg, NULL , 10);
+ if ((tmp > 0) && (tmp <= dump_level_all))
+ dump_level &= ~tmp;
+ found_args += ((*((char*)(optarg - 1)) == optchar ) ? 1 : 2);
+ break;
default:
tcpdump_usage();
return EXIT_FAILURE;
--
1.7.2.3
next prev parent reply other threads:[~2011-05-29 17:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-29 17:17 [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - add support for tt request / roaming advertisement packets Marek Lindner
2011-05-29 17:17 ` Marek Lindner [this message]
2011-05-30 11:52 ` [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - add option to select all packet types except specified Marek Lindner
2011-05-29 19:41 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - add support for tt request / roaming advertisement packets Antonio Quartulli
2011-05-30 11:51 ` Marek Lindner
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=1306689460-30162-2-git-send-email-lindner_marek@yahoo.de \
--to=lindner_marek@yahoo.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/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).