public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <a@unstable.cc>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <a@unstable.cc>,
	Antonio Quartulli <antonio@open-mesh.com>
Subject: [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently
Date: Thu, 14 Apr 2016 17:29:57 +0800	[thread overview]
Message-ID: <1460626198-31226-1-git-send-email-a@unstable.cc> (raw)

for debugging purposes it might be required to dump either OGMs
or OGM2s only. For this reason it is better to make the tcpdump
engine more flexible and accept distinct filters for the two
packet types.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 tcpdump.c | 15 ++++++++-------
 tcpdump.h | 15 ++++++++-------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/tcpdump.c b/tcpdump.c
index a30e34b..745f5d4 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -64,10 +64,11 @@ if ((size_t)(buff_len) < (check_len)) { \
 	return; \
 }
 
-static unsigned short dump_level_all = DUMP_TYPE_BATOGM | DUMP_TYPE_BATELP |
-				       DUMP_TYPE_BATICMP | DUMP_TYPE_BATUCAST |
-				       DUMP_TYPE_BATBCAST | DUMP_TYPE_BATUTVLV |
-				       DUMP_TYPE_BATFRAG | DUMP_TYPE_NONBAT;
+static unsigned short dump_level_all = DUMP_TYPE_BATOGM | DUMP_TYPE_BATOGM2 |
+				       DUMP_TYPE_BATELP | DUMP_TYPE_BATICMP |
+				       DUMP_TYPE_BATUCAST | DUMP_TYPE_BATBCAST |
+				       DUMP_TYPE_BATUTVLV | DUMP_TYPE_BATFRAG |
+				       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);
@@ -82,8 +83,8 @@ static void tcpdump_usage(void)
 	fprintf(stderr, " \t -p dump specific packet type\n");
 	fprintf(stderr, " \t -x dump all packet types except specified\n");
 	fprintf(stderr, "packet types:\n");
-	fprintf(stderr, " \t\t%3d - batman ogm/ogmv2 packets\n",
-		DUMP_TYPE_BATOGM);
+	fprintf(stderr, " \t\t%3d - batman ogm packets\n", DUMP_TYPE_BATOGM);
+	fprintf(stderr, " \t\t%3d - batman ogmv2 packets\n", DUMP_TYPE_BATOGM2);
 	fprintf(stderr, " \t\t%3d - batman elp packets\n", DUMP_TYPE_BATELP);
 	fprintf(stderr, " \t\t%3d - batman icmp packets\n", DUMP_TYPE_BATICMP);
 	fprintf(stderr, " \t\t%3d - batman unicast packets\n", DUMP_TYPE_BATUCAST);
@@ -963,7 +964,7 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read
 				dump_batman_iv_ogm(packet_buff, buff_len, read_opt, time_printed);
 			break;
 		case BATADV_OGM2:
-			if (dump_level & DUMP_TYPE_BATOGM)
+			if (dump_level & DUMP_TYPE_BATOGM2)
 				dump_batman_ogm2(packet_buff, buff_len,
 						 read_opt, time_printed);
 			break;
diff --git a/tcpdump.h b/tcpdump.h
index 5ec474f..229ee70 100644
--- a/tcpdump.h
+++ b/tcpdump.h
@@ -38,13 +38,14 @@
 #endif
 
 #define DUMP_TYPE_BATOGM 1
-#define DUMP_TYPE_BATELP 2
-#define DUMP_TYPE_BATICMP 4
-#define DUMP_TYPE_BATUCAST 8
-#define DUMP_TYPE_BATBCAST 16
-#define DUMP_TYPE_BATUTVLV 32
-#define DUMP_TYPE_BATFRAG 64
-#define DUMP_TYPE_NONBAT 128
+#define DUMP_TYPE_BATOGM2 2
+#define DUMP_TYPE_BATELP 4
+#define DUMP_TYPE_BATICMP 8
+#define DUMP_TYPE_BATUCAST 16
+#define DUMP_TYPE_BATBCAST 32
+#define DUMP_TYPE_BATUTVLV 64
+#define DUMP_TYPE_BATFRAG 128
+#define DUMP_TYPE_NONBAT 256
 
 #define IEEE80211_FCTL_FTYPE 0x0c00
 #define IEEE80211_FCTL_TODS 0x0001
-- 
2.8.1


             reply	other threads:[~2016-04-14  9:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14  9:29 Antonio Quartulli [this message]
2016-04-14  9:29 ` [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - use proper format string when printing help message Antonio Quartulli
2016-05-02 14:04   ` Marek Lindner
2016-05-02 14:10     ` Antonio Quartulli
2016-05-02 14:39       ` Sven Eckelmann
2016-05-02 13:17 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently 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=1460626198-31226-1-git-send-email-a@unstable.cc \
    --to=a@unstable.cc \
    --cc=antonio@open-mesh.com \
    --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