public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Sven Eckelmann" <sven@narfation.org>,
	"Martin Hundebøll" <martin@hundeboll.net>
Subject: [PATCH 2/3] batctl: tcpdump: Add support for unicast fragmentation
Date: Sun,  9 Jun 2019 18:56:51 +0200	[thread overview]
Message-ID: <20190609165652.12841-3-sven@narfation.org> (raw)
In-Reply-To: <20190609165652.12841-1-sven@narfation.org>

The support for unicast fragmentation was implemented in commit
9b3eab61754d ("batman-adv: Receive fragmented packets and merge"). The
support to identify such packets by batctl's tcpdump was never implemented.

This minimal implementation allows to identify these packets but is not
able to reassemble the packets. Wireshark should be used when this advanced
feature is required.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Cc: Martin Hundebøll <martin@hundeboll.net>

 tcpdump.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tcpdump.c b/tcpdump.c
index 9153fc4..7d04dd5 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -930,6 +930,30 @@ static void dump_batman_ucast(unsigned char *packet_buff, ssize_t buff_len, int
 		      read_opt, time_printed);
 }
 
+static void dump_batman_ucast_frag(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
+{
+	struct batadv_frag_packet *frag_packet;
+	struct ether_header *ether_header;
+
+	LEN_CHECK((size_t)buff_len - sizeof(*ether_header),
+		  sizeof(*frag_packet), "BAT UCAST FRAG");
+
+	ether_header = (struct ether_header *)packet_buff;
+	frag_packet = (struct batadv_frag_packet *)(packet_buff + sizeof(*ether_header));
+
+	if (!time_printed)
+		time_printed = print_time();
+
+	printf("BAT %s > ",
+	       get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost,
+				   read_opt));
+
+	printf("%s: UCAST FRAG, seqno %d, no %d, ttl %hhu\n",
+	       get_name_by_macaddr((struct ether_addr *)frag_packet->dest,
+				   read_opt),
+	       frag_packet->seqno, frag_packet->no, frag_packet->ttl);
+}
+
 static void dump_batman_bcast(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
 {
 	struct ether_header *ether_header;
@@ -1041,6 +1065,10 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read
 			if (dump_level & DUMP_TYPE_BATUCAST)
 				dump_batman_ucast(packet_buff, buff_len, read_opt, time_printed);
 			break;
+		case BATADV_UNICAST_FRAG:
+			if (dump_level & DUMP_TYPE_BATFRAG)
+				dump_batman_ucast_frag(packet_buff, buff_len, read_opt, time_printed);
+			break;
 		case BATADV_BCAST:
 			if (dump_level & DUMP_TYPE_BATBCAST)
 				dump_batman_bcast(packet_buff, buff_len, read_opt, time_printed);
-- 
2.20.1


  parent reply	other threads:[~2019-06-09 16:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-09 16:56 [PATCH 0/3] batctl: tcpdump: Add support to identify missing packets Sven Eckelmann
2019-06-09 16:56 ` [PATCH 1/3] batctl: tcpdump: Add support for MCAST TVLV Sven Eckelmann
2019-06-09 16:56 ` Sven Eckelmann [this message]
2019-06-09 16:56 ` [PATCH 3/3] batctl: tcpdump: Add support for coded packets Sven Eckelmann

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=20190609165652.12841-3-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=martin@hundeboll.net \
    /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