From owner-svn-src-head@FreeBSD.ORG Thu Jul 15 14:34:57 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 997D81065674; Thu, 15 Jul 2010 14:34:57 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 702D28FC25; Thu, 15 Jul 2010 14:34:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6FEYv0t013936; Thu, 15 Jul 2010 14:34:57 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6FEYvLP013934; Thu, 15 Jul 2010 14:34:57 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201007151434.o6FEYvLP013934@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 15 Jul 2010 14:34:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210118 - head/sbin/ipfw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 14:34:57 -0000 Author: luigi Date: Thu Jul 15 14:34:56 2010 New Revision: 210118 URL: http://svn.freebsd.org/changeset/base/210118 Log: better printing of headers when listing flows Modified: head/sbin/ipfw/dummynet.c Modified: head/sbin/ipfw/dummynet.c ============================================================================== --- head/sbin/ipfw/dummynet.c Thu Jul 15 13:46:30 2010 (r210117) +++ head/sbin/ipfw/dummynet.c Thu Jul 15 14:34:56 2010 (r210118) @@ -146,10 +146,6 @@ print_mask(struct ipfw_flow_id *id) id->proto, id->src_ip, id->src_port, id->dst_ip, id->dst_port); - - printf("BKT Prot ___Source IP/port____ " - "____Dest. IP/port____ " - "Tot_pkt/bytes Pkt/Byte Drp\n"); } else { char buf[255]; printf("\n mask: %sproto: 0x%02x, flow_id: 0x%08x, ", @@ -159,22 +155,35 @@ print_mask(struct ipfw_flow_id *id) printf("%s/0x%04x -> ", buf, id->src_port); inet_ntop(AF_INET6, &(id->dst_ip6), buf, sizeof(buf)); printf("%s/0x%04x\n", buf, id->dst_port); + } +} +static void +print_header(struct ipfw_flow_id *id) +{ + if (!IS_IP6_FLOW_ID(id)) + printf("BKT Prot ___Source IP/port____ " + "____Dest. IP/port____ " + "Tot_pkt/bytes Pkt/Byte Drp\n"); + else printf("BKT ___Prot___ _flow-id_ " "______________Source IPv6/port_______________ " "_______________Dest. IPv6/port_______________ " "Tot_pkt/bytes Pkt/Byte Drp\n"); - } } static void -list_flow(struct dn_flow *ni) +list_flow(struct dn_flow *ni, int *print) { char buff[255]; - struct protoent *pe; + struct protoent *pe = NULL; struct in_addr ina; struct ipfw_flow_id *id = &ni->fid; + if (*print) { + print_header(&ni->fid); + *print = 0; + } pe = getprotobynumber(id->proto); /* XXX: Should check for IPv4 flows */ printf("%3u%c", (ni->oid.id) & 0xff, @@ -290,6 +299,7 @@ static void list_pipes(struct dn_id *oid, struct dn_id *end) { char buf[160]; /* pending buffer */ + int toPrint = 1; /* print header */ buf[0] = '\0'; for (; oid != end; oid = O_NEXT(oid, oid->len)) { @@ -333,7 +343,7 @@ list_pipes(struct dn_id *oid, struct dn_ break; case DN_FLOW: - list_flow((struct dn_flow *)oid); + list_flow((struct dn_flow *)oid, &toPrint); break; case DN_LINK: {