All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently
@ 2016-04-14  9:29 Antonio Quartulli
  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 13:17 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently Marek Lindner
  0 siblings, 2 replies; 6+ messages in thread
From: Antonio Quartulli @ 2016-04-14  9:29 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli, Antonio Quartulli

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - use proper format string when printing help message
  2016-04-14  9:29 [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently Antonio Quartulli
@ 2016-04-14  9:29 ` Antonio Quartulli
  2016-05-02 14:04   ` Marek Lindner
  2016-05-02 13:17 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently Marek Lindner
  1 sibling, 1 reply; 6+ messages in thread
From: Antonio Quartulli @ 2016-04-14  9:29 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli, Antonio Quartulli

this patch fixes warning like this

tcpdump.c:86:18: warning: format ‘%d’ expects argument of type ‘int’, but
argument 3 has type ‘long unsigned int’ [-Wformat=]

when comiling with gcc-5.3

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 tcpdump.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tcpdump.c b/tcpdump.c
index 745f5d4..a036b93 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -83,16 +83,16 @@ 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 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);
-	fprintf(stderr, " \t\t%3d - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
-	fprintf(stderr, " \t\t%3d - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
-	fprintf(stderr, " \t\t%3d - batman unicast tvlv packets\n", DUMP_TYPE_BATUTVLV);
-	fprintf(stderr, " \t\t%3d - non batman packets\n", DUMP_TYPE_NONBAT);
-	fprintf(stderr, " \t\t%3d - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
+	fprintf(stderr, " \t\t%3lu - batman ogm packets\n", DUMP_TYPE_BATOGM);
+	fprintf(stderr, " \t\t%3lu - batman ogmv2 packets\n", DUMP_TYPE_BATOGM2);
+	fprintf(stderr, " \t\t%3lu - batman elp packets\n", DUMP_TYPE_BATELP);
+	fprintf(stderr, " \t\t%3lu - batman icmp packets\n", DUMP_TYPE_BATICMP);
+	fprintf(stderr, " \t\t%3lu - batman unicast packets\n", DUMP_TYPE_BATUCAST);
+	fprintf(stderr, " \t\t%3lu - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
+	fprintf(stderr, " \t\t%3lu - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
+	fprintf(stderr, " \t\t%3lu - batman unicast tvlv packets\n", DUMP_TYPE_BATUTVLV);
+	fprintf(stderr, " \t\t%3lu - non batman packets\n", DUMP_TYPE_NONBAT);
+	fprintf(stderr, " \t\t%3lu - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
 }
 
 static int print_time(void)
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently
  2016-04-14  9:29 [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently Antonio Quartulli
  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 13:17 ` Marek Lindner
  1 sibling, 0 replies; 6+ messages in thread
From: Marek Lindner @ 2016-05-02 13:17 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli, Antonio Quartulli

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

On Thursday, April 14, 2016 17:29:57 Antonio Quartulli wrote:
> 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(-)

Applied in revision f29682c.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - use proper format string when printing help 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
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Lindner @ 2016-05-02 14:04 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

[-- Attachment #1: Type: text/plain, Size: 3501 bytes --]

On Thursday, April 14, 2016 17:29:58 Antonio Quartulli wrote:
> +       fprintf(stderr, " \t\t%3lu - batman ogm packets\n",
> DUMP_TYPE_BATOGM); +       fprintf(stderr, " \t\t%3lu - batman ogmv2
> packets\n", DUMP_TYPE_BATOGM2); +       fprintf(stderr, " \t\t%3lu - batman
> elp packets\n", DUMP_TYPE_BATELP); +       fprintf(stderr, " \t\t%3lu -
> batman icmp packets\n", DUMP_TYPE_BATICMP); +       fprintf(stderr, "
> \t\t%3lu - batman unicast packets\n", DUMP_TYPE_BATUCAST);
> +       fprintf(stderr, " \t\t%3lu - batman broadcast packets\n",
> DUMP_TYPE_BATBCAST); +       fprintf(stderr, " \t\t%3lu - batman fragmented
> packets\n", DUMP_TYPE_BATFRAG); +       fprintf(stderr, " \t\t%3lu - batman
> unicast tvlv packets\n", DUMP_TYPE_BATUTVLV); +       fprintf(stderr, "
> \t\t%3lu - non batman packets\n", DUMP_TYPE_NONBAT);
> +       fprintf(stderr, " \t\t%3lu - batman ogm & non batman packets\n",
> DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);

$ make
    CC tcpdump.o
tcpdump.c: In function ‘tcpdump_usage’:
tcpdump.c:86:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman ogm packets\n", DUMP_TYPE_BATOGM);
                  ^
tcpdump.c:87:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman ogmv2 packets\n", DUMP_TYPE_BATOGM2);
                  ^
tcpdump.c:88:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman elp packets\n", DUMP_TYPE_BATELP);
                  ^
tcpdump.c:89:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman icmp packets\n", DUMP_TYPE_BATICMP);
                  ^
tcpdump.c:90:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman unicast packets\n", DUMP_TYPE_BATUCAST);
                  ^
tcpdump.c:91:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman broadcast packets\n", 
DUMP_TYPE_BATBCAST);
                  ^
tcpdump.c:92:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman fragmented packets\n", 
DUMP_TYPE_BATFRAG);
                  ^
tcpdump.c:93:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman unicast tvlv packets\n", 
DUMP_TYPE_BATUTVLV);
                  ^
tcpdump.c:94:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - non batman packets\n", DUMP_TYPE_NONBAT);
                  ^
tcpdump.c:95:18: warning: format ‘%lu’ expects argument of type ‘long unsigned 
int’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, " \t\t%3lu - batman ogm & non batman packets\n", 
DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
                  ^

Cheers,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - use proper format string when printing help message
  2016-05-02 14:04   ` Marek Lindner
@ 2016-05-02 14:10     ` Antonio Quartulli
  2016-05-02 14:39       ` Sven Eckelmann
  0 siblings, 1 reply; 6+ messages in thread
From: Antonio Quartulli @ 2016-05-02 14:10 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

On Mon, May 02, 2016 at 10:04:13PM +0800, Marek Lindner wrote:
> On Thursday, April 14, 2016 17:29:58 Antonio Quartulli wrote:

[..]

as explained in the original commit, I was getting the "opposite" warning. Now I
don't get it anymore. Not sure why.

I'd just suggest to drop the patch.

Cheers,



-- 
Antonio Quartulli

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - use proper format string when printing help message
  2016-05-02 14:10     ` Antonio Quartulli
@ 2016-05-02 14:39       ` Sven Eckelmann
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2016-05-02 14:39 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

On Monday 02 May 2016 22:10:41 Antonio Quartulli wrote:
> On Mon, May 02, 2016 at 10:04:13PM +0800, Marek Lindner wrote:
> > On Thursday, April 14, 2016 17:29:58 Antonio Quartulli wrote:
> 
> [..]
> 
> as explained in the original commit, I was getting the "opposite" warning. Now I
> don't get it anymore. Not sure why.
> 
> I'd just suggest to drop the patch.

You most likely had a different patch which used BIT(x) for DUMP_TYPE_* [1].

Kind regards,
	Sven

[1] https://patchwork.open-mesh.org/patch/4084/

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-02 14:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14  9:29 [B.A.T.M.A.N.] [PATCH 1/2] batctl: tcpdump - filter OGM and OGMv2 packets independently Antonio Quartulli
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.