Home | History | Annotate | Line # | Download | only in lib
      1 /*	$NetBSD: printmask.c,v 1.2 2012/07/22 14:27:37 darrenr Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 2012 by Darren Reed.
      5  *
      6  * See the IPFILTER.LICENCE file for details on licencing.
      7  *
      8  * Id: printmask.c,v 1.1.1.2 2012/07/22 13:44:41 darrenr Exp $
      9  */
     10 
     11 #include "ipf.h"
     12 
     13 
     14 void
     15 printmask(family, mask)
     16 	int	family;
     17 	u_32_t	*mask;
     18 {
     19 	struct in_addr ipa;
     20 	int ones;
     21 
     22 	if (family == AF_INET6) {
     23 		PRINTF("/%d", count6bits(mask));
     24 	} else if ((ones = count4bits(*mask)) == -1) {
     25 		ipa.s_addr = *mask;
     26 		PRINTF("/%s", inet_ntoa(ipa));
     27 	} else {
     28 		PRINTF("/%d", ones);
     29 	}
     30 }
     31