Date: Thu, 15 Jul 2010 14:34:57 +0000 (UTC) From: Luigi Rizzo <luigi@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r210118 - head/sbin/ipfw Message-ID: <201007151434.o6FEYvLP013934@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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: {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007151434.o6FEYvLP013934>