From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Apr 15 13:40:18 2003 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9858737B405 for ; Tue, 15 Apr 2003 13:40:18 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B558E43F93 for ; Tue, 15 Apr 2003 13:40:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3FKeHUp035075 for ; Tue, 15 Apr 2003 13:40:17 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3FKeHF2035074; Tue, 15 Apr 2003 13:40:17 -0700 (PDT) Resent-Date: Tue, 15 Apr 2003 13:40:17 -0700 (PDT) Resent-Message-Id: <200304152040.h3FKeHF2035074@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Luigi Rizzo Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D2F237B404 for ; Tue, 15 Apr 2003 13:31:58 -0700 (PDT) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id B809F43FAF for ; Tue, 15 Apr 2003 13:31:56 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.8p1/8.12.3) with ESMTP id h3FKVuBp028068; Tue, 15 Apr 2003 13:31:56 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.8p1/8.12.3/Submit) id h3FKVtEq028067; Tue, 15 Apr 2003 13:31:55 -0700 (PDT) (envelope-from rizzo) Message-Id: <200304152031.h3FKVtEq028067@xorpc.icir.org> Date: Tue, 15 Apr 2003 13:31:55 -0700 (PDT) From: Luigi Rizzo To: FreeBSD-gnats-submit@FreeBSD.org, ryan@sasknow.com X-Send-Pr-Version: 3.113 Subject: ports/51002: new feature for net/trafshow X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Luigi Rizzo List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Apr 2003 20:40:18 -0000 >Number: 51002 >Category: ports >Synopsis: new feature for net/trafshow >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Apr 15 13:40:17 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Luigi Rizzo >Release: FreeBSD 4.8-RELEASE i386 >Organization: Universita` di Pisa >Environment: System: FreeBSD xorpc.icir.org 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Mon Apr 7 20:59:56 PDT 2003 root@xorpc.icir.org:/usr/src/sys/compile/ICIR-4.8-USB i386 >Description: the attached patch implements a new option for net/trafsnow. From the manpage: -m [src-ip M] [dst-ip M] [src-port M] [dst-port M] [proto M] Mask the specified field with mask M (which should be specified as an hex number e.g. 0xffff0000) before further processing of the packet. This allows to aggregate traffic in the display to ease analysis. >How-To-Repeat: >Fix: attached is a patch to put in ports/net/trafshow/files/patch-mask --- display.c.orig Sun Aug 23 21:51:48 1998 +++ display.c Fri Dec 6 12:17:55 2002 @@ -54,6 +54,7 @@ static int l_nflag, l_eflag; static int n_entries; static int err_pos; +extern struct t_entry t_mask; /* traffic mask */ void init_display(reinit) @@ -282,6 +284,13 @@ packets_total++; bytes_total += e->bytes; j = page * page_size; + + e->src.s_addr &= t_mask.src.s_addr; + e->dst.s_addr &= t_mask.dst.s_addr; + e->sport &= t_mask.sport; + e->dport &= t_mask.dport; + e->proto &= t_mask.proto; + for (i = 0; i < n_entry; i++) { if (memcmp(&e->eh, &entries[i].eh, sizeof(e->eh)) == 0 && e->src.s_addr == entries[i].src.s_addr && --- trafshow.c.orig Fri Aug 28 00:15:57 1998 +++ trafshow.c Fri Dec 6 12:34:09 2002 @@ -48,6 +48,7 @@ int pflag = 0; /* don't put the interface into promiscuous mode */ int kflag = 1; /* disable keyboard input checking */ int eflag = 0; /* show ethernet traffic rather than ip */ +struct t_entry t_mask; /* traffic mask */ /* global variables */ char *program_name; /* myself */ @@ -78,6 +79,12 @@ extern int abort_on_misalignment(); extern pcap_handler lookup_if(); + t_mask.src.s_addr = 0xffffffff; /* all bits valid */ + t_mask.dst.s_addr = 0xffffffff; /* all bits valid */ + t_mask.sport = 0xffff; /* all bits valid */ + t_mask.dport = 0xffff; /* all bits valid */ + t_mask.proto = 0xffff; /* all bits valid */ + cnt = -1; device_name = NULL; infile = NULL; @@ -94,7 +87,7 @@ if (abort_on_misalignment(ebuf) < 0) error(0, ebuf); - while ((op = getopt(argc, argv, "c:CefF:i:knNOpr:t:vh?")) != EOF) + while ((op = getopt(argc, argv, "c:CefF:i:kmnNOpr:t:vh?")) != EOF) switch (op) { case 'C': #ifdef HAVE_SLCURSES @@ -114,6 +121,42 @@ break; case 'k': kflag = 0; + break; + case 'm': + fprintf(stderr, "option m %d %d\n", optind, argc); + t_mask.src.s_addr = 0; + t_mask.dst.s_addr = 0; + t_mask.sport = 0; + t_mask.dport = 0; + t_mask.proto = 0; + for (;optind + 1 <= argc;) { + char *s = argv[optind]; + u_int32_t arg = 0xffffffff; + int save=optind; + + optind++; + if (optind + 1 <= argc && + isdigit(*(argv[optind])) ) { + arg = strtol(argv[optind], NULL, 0); + optind++; + } + fprintf(stderr, "-m %s 0x%x\n", s, arg); + + if (!strcmp(s, "src-ip")) + t_mask.src.s_addr = arg; + else if (!strcmp(s, "dst-ip")) + t_mask.dst.s_addr = arg; + else if (!strcmp(s, "src-port")) + t_mask.sport = (u_short)(arg); + else if (!strcmp(s, "dst-port")) + t_mask.dport = (u_short)(arg); + else if (!strcmp(s, "proto")) + t_mask.proto = arg; + else { + optind = save; + break; + } + } break; case 'n': ++nflag; --- trafshow.1.orig Fri Aug 28 09:37:38 1998 +++ trafshow.1 Tue Apr 15 22:32:21 2003 @@ -42,6 +42,14 @@ .B \-k Disable input keyboard checking. It is intended to avoid loss of packets. .TP +.B \-m +[src-ip M] [dst-ip M] [src-port M] [dst-port M] [proto M] +.br +Mask the specified field with mask M (which should be specified +as an hex number e.g. 0xffff0000) before further processing +of the packet. This allows to aggregate traffic in the display +to ease analysis. +.TP .B \-n Don't convert host addresses and port numbers to names. .TP >Release-Note: >Audit-Trail: >Unformatted: