aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/flowctl
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@FreeBSD.org>2011-07-06 15:18:32 +0000
committerSergey Kandaurov <pluknet@FreeBSD.org>2011-07-06 15:18:32 +0000
commit6765aefcf3c30bb1d385af11d62714f1516380f3 (patch)
tree797ab012d402b8639e306ba4de0fe5d5b7853900 /usr.sbin/flowctl
parent91a1929f0722140afa9872423c9d07aa19b5fb0a (diff)
downloadsrc-6765aefcf3c30bb1d385af11d62714f1516380f3.tar.gz
src-6765aefcf3c30bb1d385af11d62714f1516380f3.zip
Conditionally compile in the IPv4/IPv6 address family support.
Test it with feature_present(3), so that we do not end up with passing an unsupported version to NgSendMsg(3). Approved by: glebius
Notes
Notes: svn path=/head/; revision=223824
Diffstat (limited to 'usr.sbin/flowctl')
-rw-r--r--usr.sbin/flowctl/Makefile5
-rw-r--r--usr.sbin/flowctl/flowctl.c23
2 files changed, 24 insertions, 4 deletions
diff --git a/usr.sbin/flowctl/Makefile b/usr.sbin/flowctl/Makefile
index 60872e6328f3..a2dd37788c38 100644
--- a/usr.sbin/flowctl/Makefile
+++ b/usr.sbin/flowctl/Makefile
@@ -14,7 +14,8 @@ LDADD= -lnetgraph
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+= -DINET6
.endif
-
-CFLAGS+= -I.
+.if ${MK_INET_SUPPORT} != "no"
+CFLAGS+= -DINET
+.endif
.include <bsd.prog.mk>
diff --git a/usr.sbin/flowctl/flowctl.c b/usr.sbin/flowctl/flowctl.c
index c1db7ab141d7..4bf86f03643e 100644
--- a/usr.sbin/flowctl/flowctl.c
+++ b/usr.sbin/flowctl/flowctl.c
@@ -69,12 +69,18 @@ static const char rcs_id[] =
#define CISCO_SH_VERB_FLOW6 "%-14s %-30s %-14s %-30s %2u %3x %4x %6lu\n" \
"%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-30s %9u %8u\n\n"
+#ifdef INET
static void flow_cache_print(struct ngnf_show_header *resp);
-static void flow_cache_print6(struct ngnf_show_header *resp);
static void flow_cache_print_verbose(struct ngnf_show_header *resp);
+#endif
+#ifdef INET6
+static void flow_cache_print6(struct ngnf_show_header *resp);
static void flow_cache_print6_verbose(struct ngnf_show_header *resp);
+#endif
static void ctl_show(int, char **);
+#if defined(INET) || defined(INET6)
static void do_show(int, void (*func)(struct ngnf_show_header *));
+#endif
static void help(void);
static void execute_command(int, char **);
@@ -157,7 +163,10 @@ execute_command(int argc, char **argv)
static void
ctl_show(int argc, char **argv)
{
- int ipv4 = 1, ipv6 = 1, verbose = 0;
+ int ipv4, ipv6, verbose = 0;
+
+ ipv4 = feature_present("inet");
+ ipv6 = feature_present("inet6");
if (argc > 0 && !strncmp(argv[0], "ipv4", 4)) {
ipv6 = 0;
@@ -173,21 +182,26 @@ ctl_show(int argc, char **argv)
if (argc > 0 && !strncmp(argv[0], "verbose", strlen(argv[0])))
verbose = 1;
+#ifdef INET
if (ipv4) {
if (verbose)
do_show(4, &flow_cache_print_verbose);
else
do_show(4, &flow_cache_print);
}
+#endif
+#ifdef INET6
if (ipv6) {
if (verbose)
do_show(6, &flow_cache_print6_verbose);
else
do_show(6, &flow_cache_print6);
}
+#endif
}
+#if defined(INET) || defined(INET6)
static void
do_show(int version, void (*func)(struct ngnf_show_header *))
{
@@ -230,7 +244,9 @@ do_show(int version, void (*func)(struct ngnf_show_header *))
req.list_id = resp->list_id;
}
}
+#endif
+#ifdef INET
static void
flow_cache_print(struct ngnf_show_header *resp)
{
@@ -261,6 +277,7 @@ flow_cache_print(struct ngnf_show_header *resp)
}
}
+#endif
#ifdef INET6
static void
@@ -295,6 +312,7 @@ flow_cache_print6(struct ngnf_show_header *resp)
}
#endif
+#ifdef INET
static void
flow_cache_print_verbose(struct ngnf_show_header *resp)
{
@@ -335,6 +353,7 @@ flow_cache_print_verbose(struct ngnf_show_header *resp)
}
}
+#endif
#ifdef INET6
static void