xref: /freebsd/sbin/ipf/libipf/printnataddr.c (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
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 
14 
15 void
16 printnataddr( int v, char *base, nat_addr_t *addr, int ifidx)
17 {
18 	switch (v)
19 	{
20 	case 4 :
21 		if (addr->na_atype == FRI_NORMAL &&
22 		    addr->na_addr[0].in4.s_addr == 0) {
23 			PRINTF("0/%d", count4bits(addr->na_addr[1].in4.s_addr));
24 		} else {
25 			printaddr(AF_INET, addr->na_atype, base, ifidx,
26 				  (u_32_t *)&addr->na_addr[0].in4.s_addr,
27 				  (u_32_t *)&addr->na_addr[1].in4.s_addr);
28 		}
29 		break;
30 #ifdef USE_INET6
31 	case 6 :
32 		printaddr(AF_INET6, addr->na_atype, base, ifidx,
33 			  (u_32_t *)&addr->na_addr[0].in6,
34 			  (u_32_t *)&addr->na_addr[1].in6);
35 		break;
36 #endif
37 	default :
38 		printf("{v=%d}", v);
39 		break;
40 	}
41 }
42