xref: /freebsd/sbin/ipf/libipf/printnataddr.c (revision efeb8bffe34422937c7f8df836afb5b817366d16)
1 /*
2  * Copyright (C) 2012 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
7  */
8 
9 #include "ipf.h"
10 #include "kmem.h"
11 
12 
13 #if !defined(lint)
14 static const char rcsid[] = "@(#)$Id: printnataddr.c,v 1.4.2.2 2012/07/22 08:04:24 darren_r Exp $";
15 #endif
16 
17 
18 void
19 printnataddr( int v, char *base, nat_addr_t *addr, int ifidx)
20 {
21 	switch (v)
22 	{
23 	case 4 :
24 		if (addr->na_atype == FRI_NORMAL &&
25 		    addr->na_addr[0].in4.s_addr == 0) {
26 			PRINTF("0/%d", count4bits(addr->na_addr[1].in4.s_addr));
27 		} else {
28 			printaddr(AF_INET, addr->na_atype, base, ifidx,
29 				  (u_32_t *)&addr->na_addr[0].in4.s_addr,
30 				  (u_32_t *)&addr->na_addr[1].in4.s_addr);
31 		}
32 		break;
33 #ifdef USE_INET6
34 	case 6 :
35 		printaddr(AF_INET6, addr->na_atype, base, ifidx,
36 			  (u_32_t *)&addr->na_addr[0].in6,
37 			  (u_32_t *)&addr->na_addr[1].in6);
38 		break;
39 #endif
40 	default :
41 		printf("{v=%d}", v);
42 		break;
43 	}
44 }
45