Author: cy
Date: Mon May 15 03:39:35 2017
New Revision: 318284
URL: https://svnweb.freebsd.org/changeset/base/318284

Log:
  Just like r318173, which was for outputting IPv6 addresses in tree
  pools, implement outputting of IPv6 addresses in the ippool debug list
  of hash type pools (ippool -l -d -t hash). Currently IPv6 in ippool tree
  type pool handling is mostly implemented.
  This continues theseries 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/printhashnode.c

Modified: head/contrib/ipfilter/lib/printhashnode.c
==============================================================================
--- head/contrib/ipfilter/lib/printhashnode.c   Sun May 14 23:45:10 2017        
(r318283)
+++ head/contrib/ipfilter/lib/printhashnode.c   Mon May 15 03:39:35 2017        
(r318284)
@@ -35,18 +35,47 @@ printhashnode(iph, ipep, copyfunc, opts,
                }
                printf("\n");
        } else if ((opts & OPT_DEBUG) != 0) {
-               PRINTF("\t%d\tAddress: %s", hv,
-                       inet_ntoa(ipe.ipe_addr.in4));
-               printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
-               PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
-                       ipe.ipe_group);
+#ifdef AF_INET6
+               if (ipe.ipe_family == AF_INET6) {
+                       char buf[INET6_ADDRSTRLEN + 1];
+                       const char *str;
+
+                       buf[0] = '\0';
+                       str = inet_ntop(AF_INET6, &ipe.ipe_addr.in6,
+                               buf, sizeof(buf) - 1);
+                       if (str == NULL)
+                               str = "???";
+                       PRINTF("\t%d\tAddress: %s", hv, str);
+                       printmask(ipe.ipe_family, (u_32_t 
*)&ipe.ipe_mask.in4_addr);
+                       PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
+                               ipe.ipe_group);
+#ifdef USE_QUAD_T
+                       PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
+                              ipe.ipe_hits, ipe.ipe_bytes);
+#else
+                       PRINTF("\tHits: %lu\tBytes: %lu\n",
+                              ipe.ipe_hits, ipe.ipe_bytes);
+#endif /* USE_QUAD_T */
+               } else if (ipe.ipe_family == AF_INET) {
+#else
+               if (ipe.ipe_family == AF_INET) {
+#endif /* AF_INET6 */
+                       PRINTF("\t%d\tAddress: %s", hv,
+                               inet_ntoa(ipe.ipe_addr.in4));
+                       printmask(ipe.ipe_family, (u_32_t 
*)&ipe.ipe_mask.in4_addr);
+                       PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
+                               ipe.ipe_group);
 #ifdef USE_QUAD_T
-               PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
-                      ipe.ipe_hits, ipe.ipe_bytes);
+                       PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
+                              ipe.ipe_hits, ipe.ipe_bytes);
 #else
-               PRINTF("\tHits: %lu\tBytes: %lu\n",
-                      ipe.ipe_hits, ipe.ipe_bytes);
-#endif
+                       PRINTF("\tHits: %lu\tBytes: %lu\n",
+                              ipe.ipe_hits, ipe.ipe_bytes);
+#endif /* USE_QUAD_T */
+               } else {
+                       PRINTF("\tAddress: family: %d\n",
+                               ipe.ipe_family);
+               }
        } else {
                putchar(' ');
                printip(ipe.ipe_family, (u_32_t *)&ipe.ipe_addr.in4_addr);
_______________________________________________
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