From patchwork Sun May 29 17:17:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1087 Return-Path: Received: from nm7-vm0.bullet.mail.ukl.yahoo.com (nm7-vm0.bullet.mail.ukl.yahoo.com [217.146.183.236]) by open-mesh.org (Postfix) with SMTP id D0905154485 for ; Sun, 29 May 2011 19:19:04 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.208] by nm7.bullet.mail.ukl.yahoo.com with NNFMP; 29 May 2011 17:19:04 -0000 Received: from [217.146.183.175] by tm1.bullet.mail.ukl.yahoo.com with NNFMP; 29 May 2011 17:19:04 -0000 Received: from [127.0.0.1] by omp1016.mail.ukl.yahoo.com with NNFMP; 29 May 2011 17:19:04 -0000 X-Yahoo-Newman-Id: 5945.61402.bm@omp1016.mail.ukl.yahoo.com Received: (qmail 15436 invoked from network); 29 May 2011 17:19:03 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=3PlTCUKHTM+sQ2KZSh71tsBt9kcz1viDkFBMdjGPCynyNTvtYBqrxNlqUatPFWOBk+85AU8bgkmPMVcZQ+r1K64q/LzW34pqOETC576mWlGKIcSYF6xUV2WBrPiMlx1LoSEImVUo7u2hXrR+EDBC+4hNlpXimr5mW5s5xIX+i9s= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1306689543; bh=W3B5yAVVklBd+KfwZG0aCXh0X0/jdis0wZavyI2T3LU=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=15SpJwbQPJSamvWOLMUGOTTjBtiCuBuZWwyreuHqL9MLeVlnr0mhd3cUtHHVflgC0CPXQkc52wD08TTjburen0tQlvvVPB+4vLUXeQAfnixKRDJBbNtGgz4rK3WGIVhtslkHMv3qIAweeuP0FY2cFPyXH5K5v14Bx6GyzcoF7k0= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: IROgN2kVM1kMk3FrCaFiq3qyavoittKV89CdumLozCfDFce WDsX6VcAhoslGIujz5x3PMchyGc_km8RL3isJUtDokwZwKJwtYIU2tNKFpzZ zpKnvuXs0AqXoBNXuHSFDNpLld.iH4n.Fg5oTTpqEJKB1T0LWx5PckoxilAX 0cv9wET3drUAzROvScC9p5mMjqHyNOzjIC.RiON1MxhPlgF.G_8o9TIsDcjb 2tL.QIoaInYIyseIunmpJWZ6PzGyQkWU1.0qsB8hcppmnnPUavr8Flrs16Y_ YolLt1ggyVP3QafCf231_UG2YxWGFVruPdqgN4z97KGZUKcN9swCedQ-- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@90.35.97.226 with plain) by smtp124.mail.ukl.yahoo.com with SMTP; 29 May 2011 17:19:03 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 29 May 2011 19:17:40 +0200 Message-Id: <1306689460-30162-2-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1306689460-30162-1-git-send-email-lindner_marek@yahoo.de> References: <1306689460-30162-1-git-send-email-lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 2/2] batctl: tcpdump - add option to select all packet types except specified 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: Sun, 29 May 2011 17:19:05 -0000 Signed-off-by: Marek Lindner --- 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;