From patchwork Tue Jun 14 14:22:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1192 Return-Path: Received: from nm10-vm0.bullet.mail.ukl.yahoo.com (nm10-vm0.bullet.mail.ukl.yahoo.com [217.146.183.242]) by open-mesh.org (Postfix) with SMTP id ED519154070 for ; Tue, 14 Jun 2011 16:22:47 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.215] by nm10.bullet.mail.ukl.yahoo.com with NNFMP; 14 Jun 2011 14:22:47 -0000 Received: from [77.238.184.72] by tm8.bullet.mail.ukl.yahoo.com with NNFMP; 14 Jun 2011 14:22:47 -0000 Received: from [127.0.0.1] by smtp141.mail.ukl.yahoo.com with NNFMP; 14 Jun 2011 14:22:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1308061367; bh=UkUx67T/BRaqhM8zkgPIdd6UYySMprapz7JlvkPOE7w=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=xeCB95KrgvExfAEKdoNoO+CtgrPu0x5LvgaSSoLMgBemfykarnrY24cfkbQOOoUZvydJxQVh/tZiw4TNHuFlXKF2BeIYcyTGlb5Ja0PjP16afhrvUuty0OhykIuzo2mDyf0P1zYBUx+Y1bm/AQtfWiFnM+KCALWIHaDsbRav+IU= X-Yahoo-Newman-Id: 142420.24904.bm@smtp141.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 3UqjxTgVM1mbT1U6uh73DPbd4wtAPhBhbP93ftPw3AkJJbo IeyKVR8ox1B8EET8Pdtojs97FetZ0Ip0kLF1XtQqGFy2A_9SEsk6BERXC8fj 6y2Aj8pzscOOWRixiz1_AJFjgrmnKUEaoQe6z7HTBx5UuWut5wSNOOz90Dkl MAveG7qEtl81vkZh0u.27navWsc2i2wy..6ak7D0V77uqruYo5JFS0enmgFj KA_yiCkAQ_cOR7.nTbp_QdALegCx8P5kqkMjl6oChAV3uhxzBr12iHmMAf7a tq3A17TAQbVQxKjXy5hWtDMGnhfJop0d20PgDbz_a2S4rnzVMiBj5GQ-- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@90.61.252.3 with plain) by smtp141.mail.ukl.yahoo.com with SMTP; 14 Jun 2011 14:22:46 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 14 Jun 2011 16:22:42 +0200 Message-Id: <1308061362-28727-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.3 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH] batctl: tcpdump - cleanup tt_query packet parser X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2011 14:22:48 -0000 Signed-off-by: Marek Lindner --- tcpdump.c | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tcpdump.c b/tcpdump.c index 4e09274..5500899 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -254,6 +254,7 @@ static void dump_vlan(unsigned char *packet_buff, ssize_t buff_len, int read_opt static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { struct tt_query_packet *tt_query_packet; + char *tt_desc, *tt_data, tt_type; LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct tt_query_packet), "BAT TT"); @@ -262,17 +263,32 @@ static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int rea if (!time_printed) print_time(); + switch (tt_query_packet->flags & TT_QUERY_TYPE_MASK) { + case TT_REQUEST: + tt_desc = "request"; + tt_data = "crc"; + tt_type = 'Q'; + break; + case TT_RESPONSE: + tt_desc = "response"; + tt_data = "entries"; + tt_type = 'P'; + break; + default: + tt_desc = "unknown"; + tt_data = "unknown"; + tt_type = '?'; + break; + } + printf("BAT %s > ", get_name_by_macaddr((struct ether_addr *)tt_query_packet->src, read_opt)); - printf("%s: TT %s, ttvn %d, %s %d, ttl %2d, v %d, flags [%c%c%c], length %zu\n", + printf("%s: TT %s, ttvn %d, %s %d, ttl %2d, v %d, flags [%c%c], length %zu\n", get_name_by_macaddr((struct ether_addr *)tt_query_packet->dst, read_opt), - tt_query_packet->flags & TT_RESPONSE ? "response" : "request", - tt_query_packet->ttvn, tt_query_packet->flags & TT_RESPONSE ? "entries" : "crc", - ntohs(tt_query_packet->tt_data), tt_query_packet->ttl, tt_query_packet->version, - (tt_query_packet->flags & TT_REQUEST ? 'Q' : '.'), - (tt_query_packet->flags & TT_RESPONSE ? 'P' : '.'), - (tt_query_packet->flags & TT_FULL_TABLE ? 'F' : '.'), + tt_desc, tt_query_packet->ttvn, tt_data, ntohs(tt_query_packet->tt_data), + tt_query_packet->ttl, tt_query_packet->version, + tt_type, (tt_query_packet->flags & TT_FULL_TABLE ? 'F' : '.'), (size_t)buff_len - sizeof(struct ether_header)); }