ip_nat.h (139255) | ip_nat.h (145522) |
---|---|
1/* $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.h 145522 2005-04-25 18:43:14Z darrenr $ */ 2 |
|
1/* | 3/* |
2 * Copyright (C) 1995-2001 by Darren Reed. | 4 * Copyright (C) 1995-2001, 2003 by Darren Reed. |
3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * @(#)ip_nat.h 1.5 2/4/96 | 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * @(#)ip_nat.h 1.5 2/4/96 |
7 * $Id: ip_nat.h,v 2.17.2.14 2000/11/18 03:58:04 darrenr Exp $ 8 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.h 139255 2004-12-24 09:14:26Z darrenr $ | 9 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.h 145522 2005-04-25 18:43:14Z darrenr $ 10 * Id: ip_nat.h,v 2.90.2.9 2005/03/28 11:09:55 darrenr Exp |
9 */ 10 11#ifndef __IP_NAT_H__ 12#define __IP_NAT_H__ 13 14#ifndef SOLARIS | 11 */ 12 13#ifndef __IP_NAT_H__ 14#define __IP_NAT_H__ 15 16#ifndef SOLARIS |
15#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) | 17#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) |
16#endif 17 18#if defined(__STDC__) || defined(__GNUC__) | 18#endif 19 20#if defined(__STDC__) || defined(__GNUC__) |
19#define SIOCADNAT _IOW('r', 60, struct ipnat *) 20#define SIOCRMNAT _IOW('r', 61, struct ipnat *) 21#define SIOCGNATS _IOWR('r', 62, struct natstat *) 22#define SIOCGNATL _IOWR('r', 63, struct natlookup *) | 21#define SIOCADNAT _IOW('r', 60, struct ipfobj) 22#define SIOCRMNAT _IOW('r', 61, struct ipfobj) 23#define SIOCGNATS _IOWR('r', 62, struct ipfobj) 24#define SIOCGNATL _IOWR('r', 63, struct ipfobj) 25#define SIOCPROXY _IOWR('r', 64, struct ap_control) |
23#else | 26#else |
24#define SIOCADNAT _IOW(r, 60, struct ipnat *) 25#define SIOCRMNAT _IOW(r, 61, struct ipnat *) 26#define SIOCGNATS _IOWR(r, 62, struct natstat *) 27#define SIOCGNATL _IOWR(r, 63, struct natlookup *) | 27#define SIOCADNAT _IOW(r, 60, struct ipfobj) 28#define SIOCRMNAT _IOW(r, 61, struct ipfobj) 29#define SIOCGNATS _IOWR(r, 62, struct ipfobj) 30#define SIOCGNATL _IOWR(r, 63, struct ipfobj) 31#define SIOCPROXY _IOWR(r, 64, struct ap_control) |
28#endif 29 | 32#endif 33 |
30#undef LARGE_NAT /* define this if you're setting up a system to NAT | 34#undef LARGE_NAT /* define this if you're setting up a system to NAT |
31 * LARGE numbers of networks/hosts - i.e. in the 32 * hundreds or thousands. In such a case, you should 33 * also change the RDR_SIZE and NAT_SIZE below to more 34 * appropriate sizes. The figures below were used for 35 * a setup with 1000-2000 networks to NAT. 36 */ | 35 * LARGE numbers of networks/hosts - i.e. in the 36 * hundreds or thousands. In such a case, you should 37 * also change the RDR_SIZE and NAT_SIZE below to more 38 * appropriate sizes. The figures below were used for 39 * a setup with 1000-2000 networks to NAT. 40 */ |
37#ifndef NAT_SIZE 38# ifdef LARGE_NAT | 41#ifndef NAT_SIZE 42# ifdef LARGE_NAT |
39# define NAT_SIZE 2047 40# else 41# define NAT_SIZE 127 42# endif 43#endif | 43# define NAT_SIZE 2047 44# else 45# define NAT_SIZE 127 46# endif 47#endif |
44#ifndef RDR_SIZE 45# ifdef LARGE_NAT | 48#ifndef RDR_SIZE 49# ifdef LARGE_NAT |
46# define RDR_SIZE 2047 47# else 48# define RDR_SIZE 127 49# endif 50#endif | 50# define RDR_SIZE 2047 51# else 52# define RDR_SIZE 127 53# endif 54#endif |
51#ifndef HOSTMAP_SIZE 52# ifdef LARGE_NAT | 55#ifndef HOSTMAP_SIZE 56# ifdef LARGE_NAT |
53# define HOSTMAP_SIZE 8191 54# else 55# define HOSTMAP_SIZE 2047 56# endif 57#endif 58#ifndef NAT_TABLE_MAX | 57# define HOSTMAP_SIZE 8191 58# else 59# define HOSTMAP_SIZE 2047 60# endif 61#endif 62#ifndef NAT_TABLE_MAX |
63/* 64 * This is newly introduced and for the sake of "least surprise", the numbers 65 * present aren't what we'd normally use for creating a proper hash table. 66 */ |
|
59# ifdef LARGE_NAT 60# define NAT_TABLE_MAX 180000 61# else 62# define NAT_TABLE_MAX 30000 63# endif 64#endif | 67# ifdef LARGE_NAT 68# define NAT_TABLE_MAX 180000 69# else 70# define NAT_TABLE_MAX 30000 71# endif 72#endif |
65#ifndef NAT_TABLE_SZ 66# ifdef LARGE_NAT | 73#ifndef NAT_TABLE_SZ 74# ifdef LARGE_NAT |
67# define NAT_TABLE_SZ 16383 68# else 69# define NAT_TABLE_SZ 2047 70# endif 71#endif 72#ifndef APR_LABELLEN 73#define APR_LABELLEN 16 74#endif 75#define NAT_HW_CKSUM 0x80000000 76 77#define DEF_NAT_AGE 1200 /* 10 minutes (600 seconds) */ 78 | 75# define NAT_TABLE_SZ 16383 76# else 77# define NAT_TABLE_SZ 2047 78# endif 79#endif 80#ifndef APR_LABELLEN 81#define APR_LABELLEN 16 82#endif 83#define NAT_HW_CKSUM 0x80000000 84 85#define DEF_NAT_AGE 1200 /* 10 minutes (600 seconds) */ 86 |
87struct ipstate; |
|
79struct ap_session; 80 81typedef struct nat { | 88struct ap_session; 89 90typedef struct nat { |
82 u_long nat_age; 83 int nat_flags; 84 u_32_t nat_sumd[2]; 85 u_32_t nat_ipsumd; 86 void *nat_data; 87 struct ap_session *nat_aps; /* proxy session */ 88 struct frentry *nat_fr; /* filter rule ptr if appropriate */ 89 struct in_addr nat_inip; 90 struct in_addr nat_outip; 91 struct in_addr nat_oip; /* other ip */ 92 U_QUAD_T nat_pkts; 93 U_QUAD_T nat_bytes; 94 u_int nat_drop[2]; 95 u_short nat_oport; /* other port */ 96 u_short nat_inport; 97 u_short nat_outport; 98 u_short nat_use; 99 u_char nat_tcpstate[2]; 100 u_char nat_p; /* protocol for NAT */ 101 u_32_t nat_mssclamp; /* if != zero clamp MSS to this */ 102 struct ipnat *nat_ptr; /* pointer back to the rule */ 103 struct hostmap *nat_hm; | 91 ipfmutex_t nat_lock; |
104 struct nat *nat_next; | 92 struct nat *nat_next; |
93 struct nat **nat_pnext; |
|
105 struct nat *nat_hnext[2]; 106 struct nat **nat_phnext[2]; | 94 struct nat *nat_hnext[2]; 95 struct nat **nat_phnext[2]; |
96 struct hostmap *nat_hm; 97 void *nat_data; |
|
107 struct nat **nat_me; | 98 struct nat **nat_me; |
108 void *nat_ifp; 109 int nat_dir; 110 char nat_ifname[IFNAMSIZ]; 111#if SOLARIS || defined(__sgi) || (__FreeBSD_version >= 500043) 112 kmutex_t nat_lock; 113#endif | 99 struct ipstate *nat_state; 100 struct ap_session *nat_aps; /* proxy session */ 101 frentry_t *nat_fr; /* filter rule ptr if appropriate */ 102 struct ipnat *nat_ptr; /* pointer back to the rule */ 103 void *nat_ifps[2]; 104 void *nat_sync; 105 ipftqent_t nat_tqe; 106 u_32_t nat_flags; 107 u_32_t nat_sumd[2]; /* ip checksum delta for data segment*/ 108 u_32_t nat_ipsumd; /* ip checksum delta for ip header */ 109 u_32_t nat_mssclamp; /* if != zero clamp MSS to this */ 110 i6addr_t nat_inip6; 111 i6addr_t nat_outip6; 112 i6addr_t nat_oip6; /* other ip */ 113 U_QUAD_T nat_pkts[2]; 114 U_QUAD_T nat_bytes[2]; 115 union { 116 udpinfo_t nat_unu; 117 tcpinfo_t nat_unt; 118 icmpinfo_t nat_uni; 119 greinfo_t nat_ugre; 120 } nat_un; 121 u_short nat_oport; /* other port */ 122 u_short nat_use; 123 u_char nat_p; /* protocol for NAT */ 124 int nat_dir; 125 int nat_ref; /* reference count */ 126 int nat_hv[2]; 127 char nat_ifnames[2][LIFNAMSIZ]; 128 int nat_rev; /* 0 = forward, 1 = reverse */ |
114} nat_t; 115 | 129} nat_t; 130 |
131#define nat_inip nat_inip6.in4 132#define nat_outip nat_outip6.in4 133#define nat_oip nat_oip6.in4 134#define nat_age nat_tqe.tqe_die 135#define nat_inport nat_un.nat_unt.ts_sport 136#define nat_outport nat_un.nat_unt.ts_dport 137#define nat_type nat_un.nat_uni.ici_type 138#define nat_seq nat_un.nat_uni.ici_seq 139#define nat_id nat_un.nat_uni.ici_id 140#define nat_tcpstate nat_tqe.tqe_state 141 142/* 143 * Values for nat_dir 144 */ 145#define NAT_INBOUND 0 146#define NAT_OUTBOUND 1 147 148/* 149 * Definitions for nat_flags 150 */ 151#define NAT_TCP 0x0001 /* IPN_TCP */ 152#define NAT_UDP 0x0002 /* IPN_UDP */ 153#define NAT_ICMPERR 0x0004 /* IPN_ICMPERR */ 154#define NAT_ICMPQUERY 0x0008 /* IPN_ICMPQUERY */ 155#define NAT_SEARCH 0x0010 156#define NAT_SLAVE 0x0020 /* Slave connection for a proxy */ 157#define NAT_NOTRULEPORT 0x0040 158 159#define NAT_TCPUDP (NAT_TCP|NAT_UDP) 160#define NAT_TCPUDPICMP (NAT_TCP|NAT_UDP|NAT_ICMPERR) 161#define NAT_TCPUDPICMPQ (NAT_TCP|NAT_UDP|NAT_ICMPQUERY) 162#define NAT_FROMRULE (NAT_TCP|NAT_UDP) 163 164/* 0x0100 reserved for FI_W_SPORT */ 165/* 0x0200 reserved for FI_W_DPORT */ 166/* 0x0400 reserved for FI_W_SADDR */ 167/* 0x0800 reserved for FI_W_DADDR */ 168/* 0x1000 reserved for FI_W_NEWFR */ 169/* 0x2000 reserved for SI_CLONE */ 170/* 0x4000 reserved for SI_CLONED */ 171/* 0x8000 reserved for SI_IGNOREPKT */ 172 173#define NAT_DEBUG 0x800000 174 |
|
116typedef struct ipnat { | 175typedef struct ipnat { |
117 struct ipnat *in_next; 118 struct ipnat *in_rnext; 119 struct ipnat **in_prnext; 120 struct ipnat *in_mnext; 121 struct ipnat **in_pmnext; 122 void *in_ifp; 123 void *in_apr; 124 u_long in_space; 125 u_int in_use; 126 u_int in_hits; 127 struct in_addr in_nextip; 128 u_short in_pnext; 129 u_short in_ippip; /* IP #'s per IP# */ 130 u_32_t in_flags; /* From here to in_dport must be reflected */ 131 u_32_t in_mssclamp; /* if != zero clamp MSS to this */ 132 u_short in_spare; 133 u_short in_ppip; /* ports per IP */ 134 u_short in_port[2]; /* correctly in IPN_CMPSIZ */ 135 struct in_addr in_in[2]; 136 struct in_addr in_out[2]; 137 struct in_addr in_src[2]; 138 struct frtuc in_tuc; 139 u_int in_age[2]; /* Aging for NAT entries. Not for TCP */ 140 int in_redir; /* 0 if it's a mapping, 1 if it's a hard redir */ 141 char in_ifname[IFNAMSIZ]; 142 char in_plabel[APR_LABELLEN]; /* proxy label */ 143 char in_p; /* protocol */ | 176 struct ipnat *in_next; /* NAT rule list next */ 177 struct ipnat *in_rnext; /* rdr rule hash next */ 178 struct ipnat **in_prnext; /* prior rdr next ptr */ 179 struct ipnat *in_mnext; /* map rule hash next */ 180 struct ipnat **in_pmnext; /* prior map next ptr */ 181 struct ipftq *in_tqehead[2]; 182 void *in_ifps[2]; 183 void *in_apr; 184 char *in_comment; 185 i6addr_t in_next6; 186 u_long in_space; 187 u_long in_hits; 188 u_int in_use; 189 u_int in_hv; 190 int in_flineno; /* conf. file line number */ 191 u_short in_pnext; 192 u_char in_v; 193 u_char in_xxx; 194 /* From here to the end is covered by IPN_CMPSIZ */ 195 u_32_t in_flags; 196 u_32_t in_mssclamp; /* if != 0 clamp MSS to this */ 197 u_int in_age[2]; 198 int in_redir; /* see below for values */ 199 int in_p; /* protocol. */ 200 i6addr_t in_in[2]; 201 i6addr_t in_out[2]; 202 i6addr_t in_src[2]; 203 frtuc_t in_tuc; 204 u_short in_port[2]; 205 u_short in_ppip; /* ports per IP. */ 206 u_short in_ippip; /* IP #'s per IP# */ 207 char in_ifnames[2][LIFNAMSIZ]; 208 char in_plabel[APR_LABELLEN]; /* proxy label. */ 209 ipftag_t in_tag; |
144} ipnat_t; 145 146#define in_pmin in_port[0] /* Also holds static redir port */ 147#define in_pmax in_port[1] | 210} ipnat_t; 211 212#define in_pmin in_port[0] /* Also holds static redir port */ 213#define in_pmax in_port[1] |
148#define in_nip in_nextip.s_addr 149#define in_inip in_in[0].s_addr 150#define in_inmsk in_in[1].s_addr 151#define in_outip in_out[0].s_addr 152#define in_outmsk in_out[1].s_addr 153#define in_srcip in_src[0].s_addr 154#define in_srcmsk in_src[1].s_addr | 214#define in_nextip in_next6.in4 215#define in_nip in_next6.in4.s_addr 216#define in_inip in_in[0].in4.s_addr 217#define in_inmsk in_in[1].in4.s_addr 218#define in_outip in_out[0].in4.s_addr 219#define in_outmsk in_out[1].in4.s_addr 220#define in_srcip in_src[0].in4.s_addr 221#define in_srcmsk in_src[1].in4.s_addr |
155#define in_scmp in_tuc.ftu_scmp 156#define in_dcmp in_tuc.ftu_dcmp 157#define in_stop in_tuc.ftu_stop 158#define in_dtop in_tuc.ftu_dtop 159#define in_sport in_tuc.ftu_sport 160#define in_dport in_tuc.ftu_dport 161 | 222#define in_scmp in_tuc.ftu_scmp 223#define in_dcmp in_tuc.ftu_dcmp 224#define in_stop in_tuc.ftu_stop 225#define in_dtop in_tuc.ftu_dtop 226#define in_sport in_tuc.ftu_sport 227#define in_dport in_tuc.ftu_dport 228 |
162#define NAT_OUTBOUND 0 163#define NAT_INBOUND 1 | 229/* 230 * Bit definitions for in_flags 231 */ 232#define IPN_ANY 0x00000 233#define IPN_TCP 0x00001 234#define IPN_UDP 0x00002 235#define IPN_TCPUDP (IPN_TCP|IPN_UDP) 236#define IPN_ICMPERR 0x00004 237#define IPN_TCPUDPICMP (IPN_TCP|IPN_UDP|IPN_ICMPERR) 238#define IPN_ICMPQUERY 0x00008 239#define IPN_TCPUDPICMPQ (IPN_TCP|IPN_UDP|IPN_ICMPQUERY) 240#define IPN_RF (IPN_TCPUDP|IPN_DELETE|IPN_ICMPERR) 241#define IPN_AUTOPORTMAP 0x00010 242#define IPN_IPRANGE 0x00020 243#define IPN_FILTER 0x00040 244#define IPN_SPLIT 0x00080 245#define IPN_ROUNDR 0x00100 246#define IPN_NOTSRC 0x04000 247#define IPN_NOTDST 0x08000 248#define IPN_DYNSRCIP 0x10000 /* dynamic src IP# */ 249#define IPN_DYNDSTIP 0x20000 /* dynamic dst IP# */ 250#define IPN_DELETE 0x40000 251#define IPN_STICKY 0x80000 252#define IPN_FRAG 0x100000 253#define IPN_FIXEDDPORT 0x200000 254#define IPN_FINDFORWARD 0x400000 255#define IPN_IN 0x800000 256#define IPN_USERFLAGS (IPN_TCPUDP|IPN_AUTOPORTMAP|IPN_IPRANGE|IPN_SPLIT|\ 257 IPN_ROUNDR|IPN_FILTER|IPN_NOTSRC|IPN_NOTDST|\ 258 IPN_FRAG|IPN_STICKY|IPN_FIXEDDPORT|IPN_ICMPQUERY) |
164 | 259 |
260/* 261 * Values for in_redir 262 */ |
|
165#define NAT_MAP 0x01 166#define NAT_REDIRECT 0x02 167#define NAT_BIMAP (NAT_MAP|NAT_REDIRECT) 168#define NAT_MAPBLK 0x04 | 263#define NAT_MAP 0x01 264#define NAT_REDIRECT 0x02 265#define NAT_BIMAP (NAT_MAP|NAT_REDIRECT) 266#define NAT_MAPBLK 0x04 |
169/* 0x100 reserved for FI_W_SPORT */ 170/* 0x200 reserved for FI_W_DPORT */ 171/* 0x400 reserved for FI_W_SADDR */ 172/* 0x800 reserved for FI_W_DADDR */ 173/* 0x1000 reserved for FI_W_NEWFR */ | |
174 175#define MAPBLK_MINPORT 1024 /* don't use reserved ports for src port */ 176#define USABLE_PORTS (65536 - MAPBLK_MINPORT) 177 178#define IPN_CMPSIZ (sizeof(ipnat_t) - offsetof(ipnat_t, in_flags)) 179 180typedef struct natlookup { 181 struct in_addr nl_inip; --- 18 unchanged lines hidden (view full) --- 200#define ipn_rule ipn_nat.nat_fr 201 202typedef struct natget { 203 void *ng_ptr; 204 int ng_sz; 205} natget_t; 206 207 | 267 268#define MAPBLK_MINPORT 1024 /* don't use reserved ports for src port */ 269#define USABLE_PORTS (65536 - MAPBLK_MINPORT) 270 271#define IPN_CMPSIZ (sizeof(ipnat_t) - offsetof(ipnat_t, in_flags)) 272 273typedef struct natlookup { 274 struct in_addr nl_inip; --- 18 unchanged lines hidden (view full) --- 293#define ipn_rule ipn_nat.nat_fr 294 295typedef struct natget { 296 void *ng_ptr; 297 int ng_sz; 298} natget_t; 299 300 |
301typedef struct nattrpnt { 302 struct in_addr tr_dstip; /* real destination IP# */ 303 struct in_addr tr_srcip; /* real source IP# */ 304 struct in_addr tr_locip; /* local source IP# */ 305 u_int tr_flags; 306 int tr_expire; 307 u_short tr_dstport; /* real destination port# */ 308 u_short tr_srcport; /* real source port# */ 309 u_short tr_locport; /* local source port# */ 310 struct nattrpnt *tr_hnext; 311 struct nattrpnt **tr_phnext; 312 struct nattrpnt *tr_next; 313 struct nattrpnt **tr_pnext; /* previous next */ 314} nattrpnt_t; 315 316#define TN_CMPSIZ offsetof(nattrpnt_t, tr_hnext) 317 318 319/* 320 * This structure gets used to help NAT sessions keep the same NAT rule (and 321 * thus translation for IP address) when: 322 * (a) round-robin redirects are in use 323 * (b) different IP add 324 */ |
|
208typedef struct hostmap { 209 struct hostmap *hm_next; 210 struct hostmap **hm_pnext; 211 struct ipnat *hm_ipnat; | 325typedef struct hostmap { 326 struct hostmap *hm_next; 327 struct hostmap **hm_pnext; 328 struct ipnat *hm_ipnat; |
212 struct in_addr hm_realip; | 329 struct in_addr hm_srcip; 330 struct in_addr hm_dstip; |
213 struct in_addr hm_mapip; | 331 struct in_addr hm_mapip; |
214 int hm_ref; | 332 u_32_t hm_port; 333 int hm_ref; |
215} hostmap_t; 216 217 | 334} hostmap_t; 335 336 |
337/* 338 * Structure used to pass information in to nat_newmap and nat_newrdr. 339 */ 340typedef struct natinfo { 341 ipnat_t *nai_np; 342 u_32_t nai_sum1; 343 u_32_t nai_sum2; 344 u_32_t nai_nflags; 345 u_32_t nai_flags; 346 struct in_addr nai_ip; 347 u_short nai_port; 348 u_short nai_nport; 349 u_short nai_sport; 350 u_short nai_dport; 351} natinfo_t; 352 353 |
|
218typedef struct natstat { 219 u_long ns_mapped[2]; 220 u_long ns_rules; 221 u_long ns_added; 222 u_long ns_expire; 223 u_long ns_inuse; 224 u_long ns_logged; 225 u_long ns_logfail; 226 u_long ns_memfail; 227 u_long ns_badnat; | 354typedef struct natstat { 355 u_long ns_mapped[2]; 356 u_long ns_rules; 357 u_long ns_added; 358 u_long ns_expire; 359 u_long ns_inuse; 360 u_long ns_logged; 361 u_long ns_logfail; 362 u_long ns_memfail; 363 u_long ns_badnat; |
364 u_long ns_addtrpnt; |
|
228 nat_t **ns_table[2]; 229 hostmap_t **ns_maptable; 230 ipnat_t *ns_list; 231 void *ns_apslist; | 365 nat_t **ns_table[2]; 366 hostmap_t **ns_maptable; 367 ipnat_t *ns_list; 368 void *ns_apslist; |
369 u_int ns_wilds; |
|
232 u_int ns_nattab_sz; | 370 u_int ns_nattab_sz; |
371 u_int ns_nattab_max; |
|
233 u_int ns_rultab_sz; 234 u_int ns_rdrtab_sz; | 372 u_int ns_rultab_sz; 373 u_int ns_rdrtab_sz; |
374 u_int ns_trpntab_sz; |
|
235 u_int ns_hostmap_sz; 236 nat_t *ns_instances; | 375 u_int ns_hostmap_sz; 376 nat_t *ns_instances; |
237 u_int ns_wilds; | 377 nattrpnt_t *ns_trpntlist; 378 u_long *ns_bucketlen[2]; |
238} natstat_t; 239 | 379} natstat_t; 380 |
240#define IPN_ANY 0x000 241#define IPN_TCP 0x001 242#define IPN_UDP 0x002 243#define IPN_TCPUDP (IPN_TCP|IPN_UDP) 244#define IPN_DELETE 0x004 245#define IPN_ICMPERR 0x008 246#define IPN_RF (IPN_TCPUDP|IPN_DELETE|IPN_ICMPERR) 247#define IPN_AUTOPORTMAP 0x010 248#define IPN_IPRANGE 0x020 249#define IPN_USERFLAGS (IPN_TCPUDP|IPN_AUTOPORTMAP|IPN_IPRANGE|IPN_SPLIT|\ 250 IPN_ROUNDR|IPN_FILTER|IPN_NOTSRC|IPN_NOTDST|IPN_FRAG) 251#define IPN_FILTER 0x040 252#define IPN_SPLIT 0x080 253#define IPN_ROUNDR 0x100 254#define IPN_NOTSRC 0x080000 255#define IPN_NOTDST 0x100000 256#define IPN_FRAG 0x200000 257 258 | |
259typedef struct natlog { 260 struct in_addr nl_origip; 261 struct in_addr nl_outip; 262 struct in_addr nl_inip; 263 u_short nl_origport; 264 u_short nl_outport; 265 u_short nl_inport; 266 u_short nl_type; 267 int nl_rule; | 381typedef struct natlog { 382 struct in_addr nl_origip; 383 struct in_addr nl_outip; 384 struct in_addr nl_inip; 385 u_short nl_origport; 386 u_short nl_outport; 387 u_short nl_inport; 388 u_short nl_type; 389 int nl_rule; |
268 U_QUAD_T nl_pkts; 269 U_QUAD_T nl_bytes; | 390 U_QUAD_T nl_pkts[2]; 391 U_QUAD_T nl_bytes[2]; |
270 u_char nl_p; 271} natlog_t; 272 273 274#define NL_NEWMAP NAT_MAP 275#define NL_NEWRDR NAT_REDIRECT 276#define NL_NEWBIMAP NAT_BIMAP 277#define NL_NEWBLOCK NAT_MAPBLK | 392 u_char nl_p; 393} natlog_t; 394 395 396#define NL_NEWMAP NAT_MAP 397#define NL_NEWRDR NAT_REDIRECT 398#define NL_NEWBIMAP NAT_BIMAP 399#define NL_NEWBLOCK NAT_MAPBLK |
400#define NL_CLONE 0xfffd |
|
278#define NL_FLUSH 0xfffe 279#define NL_EXPIRE 0xffff 280 281#define NAT_HASH_FN(k,l,m) (((k) + ((k) >> 12) + l) % (m)) 282 283#define LONG_SUM(in) (((in) & 0xffff) + ((in) >> 16)) 284 285#define CALC_SUMD(s1, s2, sd) { \ --- 5 unchanged lines hidden (view full) --- 291 /* Because ~1 == -2, We really need ~1 == -1 */ \ 292 if ((s1) > (s2)) (s2)--; \ 293 (sd) = (s2) - (s1); \ 294 (sd) = ((sd) & 0xffff) + ((sd) >> 16); } 295 296#define NAT_SYSSPACE 0x80000000 297#define NAT_LOCKHELD 0x40000000 298 | 401#define NL_FLUSH 0xfffe 402#define NL_EXPIRE 0xffff 403 404#define NAT_HASH_FN(k,l,m) (((k) + ((k) >> 12) + l) % (m)) 405 406#define LONG_SUM(in) (((in) & 0xffff) + ((in) >> 16)) 407 408#define CALC_SUMD(s1, s2, sd) { \ --- 5 unchanged lines hidden (view full) --- 414 /* Because ~1 == -2, We really need ~1 == -1 */ \ 415 if ((s1) > (s2)) (s2)--; \ 416 (sd) = (s2) - (s1); \ 417 (sd) = ((sd) & 0xffff) + ((sd) >> 16); } 418 419#define NAT_SYSSPACE 0x80000000 420#define NAT_LOCKHELD 0x40000000 421 |
422 |
|
299extern u_int ipf_nattable_sz; | 423extern u_int ipf_nattable_sz; |
424extern u_int ipf_nattable_max; |
|
300extern u_int ipf_natrules_sz; 301extern u_int ipf_rdrrules_sz; | 425extern u_int ipf_natrules_sz; 426extern u_int ipf_rdrrules_sz; |
427extern u_int ipf_hostmap_sz; 428extern u_int fr_nat_maxbucket; 429extern u_int fr_nat_maxbucket_reset; |
|
302extern int fr_nat_lock; | 430extern int fr_nat_lock; |
303extern void ip_natsync __P((void *)); | 431extern void fr_natsync __P((void *)); |
304extern u_long fr_defnatage; 305extern u_long fr_defnaticmpage; | 432extern u_long fr_defnatage; 433extern u_long fr_defnaticmpage; |
434extern u_long fr_defnatipage; 435 /* nat_table[0] -> hashed list sorted by inside (ip, port) */ 436 /* nat_table[1] -> hashed list sorted by outside (ip, port) */ |
|
306extern nat_t **nat_table[2]; 307extern nat_t *nat_instances; | 437extern nat_t **nat_table[2]; 438extern nat_t *nat_instances; |
439extern ipnat_t *nat_list; |
|
308extern ipnat_t **nat_rules; 309extern ipnat_t **rdr_rules; | 440extern ipnat_t **nat_rules; 441extern ipnat_t **rdr_rules; |
310extern ipnat_t *nat_list; | 442extern ipftq_t *nat_utqe; |
311extern natstat_t nat_stats; | 443extern natstat_t nat_stats; |
444 |
|
312#if defined(__OpenBSD__) 313extern void nat_ifdetach __P((void *)); 314#endif | 445#if defined(__OpenBSD__) 446extern void nat_ifdetach __P((void *)); 447#endif |
315#if defined(__NetBSD__) || defined(__OpenBSD__) || (__FreeBSD_version >= 300003) 316extern int nat_ioctl __P((caddr_t, u_long, int)); 317#else 318extern int nat_ioctl __P((caddr_t, int, int)); 319#endif 320extern int nat_init __P((void)); 321extern nat_t *nat_new __P((fr_info_t *, ip_t *, ipnat_t *, nat_t **, 322 u_int, int)); | 448extern int fr_nat_ioctl __P((caddr_t, ioctlcmd_t, int)); 449extern int fr_natinit __P((void)); 450extern nat_t *nat_new __P((fr_info_t *, ipnat_t *, nat_t **, u_int, int)); |
323extern nat_t *nat_outlookup __P((fr_info_t *, u_int, u_int, struct in_addr, | 451extern nat_t *nat_outlookup __P((fr_info_t *, u_int, u_int, struct in_addr, |
324 struct in_addr, int)); | 452 struct in_addr)); 453extern void fix_datacksum __P((u_short *, u_32_t)); |
325extern nat_t *nat_inlookup __P((fr_info_t *, u_int, u_int, struct in_addr, | 454extern nat_t *nat_inlookup __P((fr_info_t *, u_int, u_int, struct in_addr, |
326 struct in_addr, int)); | 455 struct in_addr)); 456extern nat_t *nat_tnlookup __P((fr_info_t *, int)); 457extern nat_t *nat_maplookup __P((void *, u_int, struct in_addr, 458 struct in_addr)); |
327extern nat_t *nat_lookupredir __P((natlookup_t *)); | 459extern nat_t *nat_lookupredir __P((natlookup_t *)); |
328extern nat_t *nat_icmplookup __P((ip_t *, fr_info_t *, int)); 329extern nat_t *nat_icmp __P((ip_t *, fr_info_t *, u_int *, int)); 330extern int nat_clearlist __P((void)); 331extern void nat_insert __P((nat_t *)); | 460extern nat_t *nat_icmperrorlookup __P((fr_info_t *, int)); 461extern nat_t *nat_icmperror __P((fr_info_t *, u_int *, int)); 462extern int nat_insert __P((nat_t *, int)); |
332 | 463 |
333extern int ip_natout __P((ip_t *, fr_info_t *)); 334extern int ip_natin __P((ip_t *, fr_info_t *)); 335extern void ip_natunload __P((void)), ip_natexpire __P((void)); | 464extern int fr_checknatout __P((fr_info_t *, u_32_t *)); 465extern int fr_natout __P((fr_info_t *, nat_t *, int, u_32_t)); 466extern int fr_checknatin __P((fr_info_t *, u_32_t *)); 467extern int fr_natin __P((fr_info_t *, nat_t *, int, u_32_t)); 468extern void fr_natunload __P((void)); 469extern void fr_natexpire __P((void)); |
336extern void nat_log __P((struct nat *, u_int)); 337extern void fix_incksum __P((fr_info_t *, u_short *, u_32_t)); 338extern void fix_outcksum __P((fr_info_t *, u_short *, u_32_t)); | 470extern void nat_log __P((struct nat *, u_int)); 471extern void fix_incksum __P((fr_info_t *, u_short *, u_32_t)); 472extern void fix_outcksum __P((fr_info_t *, u_short *, u_32_t)); |
339extern void fix_datacksum __P((u_short *, u_32_t)); | 473extern void fr_natderef __P((nat_t **)); 474extern u_short *nat_proto __P((fr_info_t *, nat_t *, u_int)); 475extern void nat_update __P((fr_info_t *, nat_t *, ipnat_t *)); 476extern void fr_setnatqueue __P((nat_t *, int)); |
340 341#endif /* __IP_NAT_H__ */ | 477 478#endif /* __IP_NAT_H__ */ |