Author: cy
Date: Thu May 11 04:39:11 2017
New Revision: 318173
URL: https://svnweb.freebsd.org/changeset/base/318173

Log:
  Implement outputting of IPv6 addresses in the ippool debug list of tree
  type pools (ippool -l -d -t tree). Currently IPv6 in ippool tree type
  pool handling is partially implemented (meaning it doesn't work).
  This is the first of a series of commits to remediate ippool.
  
  This will be MFCed with a yet to be committed series of fixes to ippool
  after it has been fully remediated.
  
  PR:           218433

Modified:
  head/contrib/ipfilter/lib/printpoolnode.c

Modified: head/contrib/ipfilter/lib/printpoolnode.c
==============================================================================
--- head/contrib/ipfilter/lib/printpoolnode.c   Thu May 11 04:29:20 2017        
(r318172)
+++ head/contrib/ipfilter/lib/printpoolnode.c   Thu May 11 04:39:11 2017        
(r318173)
@@ -33,8 +33,30 @@ printpoolnode(np, opts, fields)
                printmask(np->ipn_addr.adf_family,
                          (u_32_t *)&np->ipn_mask.adf_addr);
        } else {
-               PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
-                       inet_ntoa(np->ipn_addr.adf_addr.in4));
+#ifdef AF_INET6
+               if (np->ipn_addr.adf_family == AF_INET6) {
+                       char buf[INET6_ADDRSTRLEN + 1];
+                       const char *str;
+                       
+                       buf[0] = '\0';
+                       str = inet_ntop(AF_INET6, &np->ipn_addr.adf_addr.in6,
+                               buf, sizeof(buf) - 1);
+                       if (str == NULL)
+                               str = "???";
+                       PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
+                               str);
+               } else if (np->ipn_addr.adf_family == AF_INET) {
+#else
+               if (np->ipn_addr.adf_family == AF_INET) {
+#endif
+                       PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
+                               inet_ntoa(np->ipn_addr.adf_addr.in4));
+               } else {
+                       PRINTF("\tAddress: family: %d",
+                               np->ipn_addr.adf_family);
+#ifdef AF_INET6
+               }
+#endif
                printmask(np->ipn_addr.adf_family,
                          (u_32_t *)&np->ipn_mask.adf_addr);
 #ifdef USE_QUAD_T
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to