Initial import from FreeBSD RELENG_4:
[games.git] / contrib / ipfilter / man / ipnat.4
1 .\" $FreeBSD: src/contrib/ipfilter/man/ipnat.4,v 1.4.2.1 2001/02/17 20:36:26 darrenr Exp $
2 .TH IPNAT 4
3 .SH NAME
4 ipnat \- Network Address Translation kernel interface
5 .SH SYNOPSIS
6 #include <netinet/ip_compat.h>
7 .br
8 #include <netinet/ip_fil.h>
9 .br
10 #include <netinet/ip_proxy.h>
11 .br
12 #include <netinet/ip_nat.h>
13 .SH IOCTLS
14 .PP
15 To add and delete rules to the NAT list, two 'basic' ioctls are provided
16 for use.  The ioctl's are called as:
17 .LP
18 .nf
19         ioctl(fd, SIOCADNAT, struct ipnat **)
20         ioctl(fd, SIOCRMNAT, struct ipnat **)
21         ioctl(fd, SIOCGNATS, struct natstat **)
22         ioctl(fd, SIOCGNATL, struct natlookup **)
23 .fi
24 .PP
25 Unlike \fBipf(4)\fP, there is only a single list supported by the kernel NAT
26 interface.  An inactive list which can be swapped to is not currently
27 supported.
28
29 These ioctl's are implemented as being routing ioctls and thus the same rules
30 for the various routing ioctls and the file descriptor are employed, mainly
31 being that the fd must be that of the device associated with the module
32 (i.e., /dev/ipl).
33 .LP
34 .PP
35 The structure used with the NAT interface is described below:
36 .LP
37 .nf
38 typedef struct  ipnat   {
39         struct  ipnat   *in_next;
40         void    *in_ifp;
41         u_short in_flags;
42         u_short in_pnext;
43         u_short in_port[2];
44         struct  in_addr in_in[2];
45         struct  in_addr in_out[2];
46         struct  in_addr in_nextip;
47         int     in_space;
48         int     in_redir; /* 0 if it's a mapping, 1 if it's a hard redir */
49         char    in_ifname[IFNAMSIZ];
50 } ipnat_t;
51
52 #define in_pmin         in_port[0]      /* Also holds static redir port */
53 #define in_pmax         in_port[1]
54 #define in_nip          in_nextip.s_addr
55 #define in_inip         in_in[0].s_addr
56 #define in_inmsk        in_in[1].s_addr
57 #define in_outip        in_out[0].s_addr
58 #define in_outmsk       in_out[1].s_addr
59
60 .fi
61 .PP
62 Recognised values for in_redir:
63 .LP
64 .nf
65 #define NAT_MAP         0
66 #define NAT_REDIRECT    1
67 .fi
68 .PP
69 .LP
70 \fBNAT statistics\fP
71 Statistics on the number of packets mapped, going in and out are kept,
72 the number of times a new entry is added and deleted (through expiration) to
73 the NAT table and the current usage level of the NAT table.
74 .PP
75 Pointers to the NAT table inside the kernel, as well as to the top of the
76 internal NAT lists constructed with the \fBSIOCADNAT\fP ioctls.  The table
77 itself is a hash table of size NAT_SIZE (default size is 367).
78 .PP
79 To retrieve the statistics, the \fBSIOCGNATS\fP ioctl must be used, with
80 the appropriate structure passed by reference, as follows:
81 .nf
82         ioctl(fd, SIOCGNATS, struct natstat *)
83
84 typedef struct  natstat {
85         u_long  ns_mapped[2];
86         u_long  ns_added;
87         u_long  ns_expire;
88         u_long  ns_inuse;
89         nat_t   ***ns_table;
90         ipnat_t *ns_list;
91 } natstat_t;
92 .fi
93 .SH BUGS
94 It would be nice if there were more flexibility when adding and deleting
95 filter rules.
96 .SH FILES
97 /dev/ipnat
98 .SH SEE ALSO
99 ipf(4), ipnat(5), ipf(8), ipnat(8), ipfstat(8)