aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipf/libipf/printmask.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ipf/libipf/printmask.c')
-rw-r--r--sbin/ipf/libipf/printmask.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sbin/ipf/libipf/printmask.c b/sbin/ipf/libipf/printmask.c
new file mode 100644
index 000000000000..bdb28d8ee4a2
--- /dev/null
+++ b/sbin/ipf/libipf/printmask.c
@@ -0,0 +1,27 @@
+
+/*
+ * Copyright (C) 2012 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ *
+ * $Id$
+ */
+
+#include "ipf.h"
+
+
+void
+printmask(int family, u_32_t *mask)
+{
+ struct in_addr ipa;
+ int ones;
+
+ if (family == AF_INET6) {
+ PRINTF("/%d", count6bits(mask));
+ } else if ((ones = count4bits(*mask)) == -1) {
+ ipa.s_addr = *mask;
+ PRINTF("/%s", inet_ntoa(ipa));
+ } else {
+ PRINTF("/%d", ones);
+ }
+}