[Midnightbsd-cvs] src [10751] trunk/usr.sbin/flowctl/flowctl.c: sync
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jun 9 18:16:17 EDT 2018
Revision: 10751
http://svnweb.midnightbsd.org/src/?rev=10751
Author: laffer1
Date: 2018-06-09 18:16:16 -0400 (Sat, 09 Jun 2018)
Log Message:
-----------
sync
Modified Paths:
--------------
trunk/usr.sbin/flowctl/Makefile
trunk/usr.sbin/flowctl/flowctl.8
trunk/usr.sbin/flowctl/flowctl.c
Property Changed:
----------------
trunk/usr.sbin/flowctl/flowctl.8
Modified: trunk/usr.sbin/flowctl/Makefile
===================================================================
--- trunk/usr.sbin/flowctl/Makefile 2018-06-09 22:15:49 UTC (rev 10750)
+++ trunk/usr.sbin/flowctl/Makefile 2018-06-09 22:16:16 UTC (rev 10751)
@@ -1,6 +1,7 @@
-#
# $MidnightBSD$
#
+# $FreeBSD: stable/10/usr.sbin/flowctl/Makefile 223824 2011-07-06 15:18:32Z pluknet $
+#
.include <bsd.own.mk>
Modified: trunk/usr.sbin/flowctl/flowctl.8
===================================================================
--- trunk/usr.sbin/flowctl/flowctl.8 2018-06-09 22:15:49 UTC (rev 10750)
+++ trunk/usr.sbin/flowctl/flowctl.8 2018-06-09 22:16:16 UTC (rev 10751)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2004-2005 Gleb Smirnoff <glebius at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -22,9 +23,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/flowctl/flowctl.8 236808 2012-06-09 10:10:12Z melifaro $
.\"
-.Dd July 5, 2011
+.Dd June 8, 2012
.Dt FLOWCTL 8
.Os
.Sh NAME
@@ -55,7 +56,7 @@
.Nm
supports only one command.
.Bl -tag -width ".Cm show"
-.It Cm show Op Cm ipv4|ipv6
+.It Cm show Oo Cm ipv4|ipv6 Oc Op Cm human|verbose
This command is the analog of the
.Dq "show ip cache flow"
command of a Cisco router.
@@ -69,7 +70,9 @@
.Cm verbose ,
which is analog of the
.Dq "show ip cache verbose flow"
-command.
+command. Additionally,
+.Cm human
+parameter can be specify to show selected flows in human-readable format.
.El
.Sh EXIT STATUS
.Ex -std
Property changes on: trunk/usr.sbin/flowctl/flowctl.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/flowctl/flowctl.c
===================================================================
--- trunk/usr.sbin/flowctl/flowctl.c 2018-06-09 22:15:49 UTC (rev 10750)
+++ trunk/usr.sbin/flowctl/flowctl.c 2018-06-09 22:16:16 UTC (rev 10751)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004-2005 Gleb Smirnoff <glebius at FreeBSD.org>
* Copyright (c) 2001-2003 Roman V. Palagin <romanp at unshadow.net>
@@ -29,7 +30,7 @@
#ifndef lint
static const char rcs_id[] =
- "@(#) $MidnightBSD$";
+ "@(#) $FreeBSD: stable/10/usr.sbin/flowctl/flowctl.c 236808 2012-06-09 10:10:12Z melifaro $";
#endif
#include <sys/types.h>
@@ -52,19 +53,33 @@
#include <netgraph.h>
#include <netgraph/netflow/ng_netflow.h>
-#define CISCO_SH_FLOW_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts\n"
+#define CISCO_SH_FLOW_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr SrcP DstP Pkts\n"
#define CISCO_SH_FLOW "%-13s %-15s %-13s %-15s %2u %4.4x %4.4x %6lu\n"
-#define CISCO_SH_FLOW6_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts\n"
-#define CISCO_SH_FLOW6 "%-13s %-30s %-13s %-30s %2u %4.4x %4.4x %6lu\n"
+/* human-readable IPv4 header */
+#define CISCO_SH_FLOW_HHEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Proto SrcPort DstPort Pkts\n"
+#define CISCO_SH_FLOW_H "%-13s %-15s %-13s %-15s %5u %8d %8d %8lu\n"
-#define CISCO_SH_VERB_FLOW_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
+#define CISCO_SH_FLOW6_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr SrcP DstP Pkts\n"
+#define CISCO_SH_FLOW6 "%-13s %-30s %-13s %-30s %2u %4.4x %4.4x %6lu\n"
+
+/* Human-readable IPv6 headers */
+#define CISCO_SH_FLOW6_HHEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Proto SrcPort DstPort Pkts\n"
+#define CISCO_SH_FLOW6_H "%-13s %-36s %-13s %-36s %5u %8d %8d %8lu\n"
+
+#define CISCO_SH_VERB_FLOW_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
"Port Msk AS Port Msk AS NextHop B/Pk Active\n"
#define CISCO_SH_VERB_FLOW "%-14s %-15s %-14s %-15s %2u %3x %4x %6lu\n" \
"%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-15s %9u %8u\n\n"
-#define CISCO_SH_VERB_FLOW6_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
+#define CISCO_SH_VERB_FLOW6_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
"Port Msk AS Port Msk AS NextHop B/Pk Active\n"
#define CISCO_SH_VERB_FLOW6 "%-14s %-30s %-14s %-30s %2u %3x %4x %6lu\n" \
@@ -94,7 +109,7 @@
{NULL, NULL},
};
-int cs;
+int cs, human = 0;
char *ng_path;
int
@@ -182,6 +197,9 @@
if (argc > 0 && !strncmp(argv[0], "verbose", strlen(argv[0])))
verbose = 1;
+ if (argc > 0 && !strncmp(argv[0], "human", strlen(argv[0])))
+ human = 1;
+
#ifdef INET
if (ipv4) {
if (verbose)
@@ -259,13 +277,14 @@
errx(EX_SOFTWARE, "%s: version mismatch: %u",
__func__, resp->version);
- printf(CISCO_SH_FLOW_HEADER);
+ if (resp->nentries > 0)
+ printf(human ? CISCO_SH_FLOW_HHEADER : CISCO_SH_FLOW_HEADER);
fle = (struct flow_entry_data *)(resp + 1);
for (i = 0; i < resp->nentries; i++, fle++) {
inet_ntop(AF_INET, &fle->r.r_src, src, sizeof(src));
inet_ntop(AF_INET, &fle->r.r_dst, dst, sizeof(dst));
- printf(CISCO_SH_FLOW,
+ printf(human ? CISCO_SH_FLOW_H : CISCO_SH_FLOW,
if_indextoname(fle->fle_i_ifx, src_if),
src,
if_indextoname(fle->fle_o_ifx, dst_if),
@@ -292,13 +311,14 @@
errx(EX_SOFTWARE, "%s: version mismatch: %u",
__func__, resp->version);
- printf(CISCO_SH_FLOW6_HEADER);
+ if (resp->nentries > 0)
+ printf(human ? CISCO_SH_FLOW6_HHEADER : CISCO_SH_FLOW6_HEADER);
fle6 = (struct flow6_entry_data *)(resp + 1);
for (i = 0; i < resp->nentries; i++, fle6++) {
inet_ntop(AF_INET6, &fle6->r.src.r_src6, src6, sizeof(src6));
inet_ntop(AF_INET6, &fle6->r.dst.r_dst6, dst6, sizeof(dst6));
- printf(CISCO_SH_FLOW6,
+ printf(human ? CISCO_SH_FLOW6_H : CISCO_SH_FLOW6,
if_indextoname(fle6->fle_i_ifx, src_if),
src6,
if_indextoname(fle6->fle_o_ifx, dst_if),
More information about the Midnightbsd-cvs
mailing list