]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netinet/ip_nat.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (C) 1995-1997 by Darren Reed.
25 * Redistribution and use in source and binary forms are permitted
26 * provided that this notice is preserved and due credit is given
27 * to the original author and the contributors.
29 * @(#)ip_nat.h 1.5 2/4/96
36 #define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
39 #if defined(__STDC__) || defined(__GNUC__)
40 #define SIOCADNAT _IOW('r', 80, struct ipnat)
41 #define SIOCRMNAT _IOW('r', 81, struct ipnat)
42 #define SIOCGNATS _IOR('r', 82, struct natstat)
43 #define SIOCGNATL _IOWR('r', 83, struct natlookup)
44 #define SIOCGFRST _IOR('r', 84, struct ipfrstat)
45 #define SIOCGIPST _IOR('r', 85, struct ips_stat)
46 #define SIOCFLNAT _IOWR('r', 86, int)
47 #define SIOCCNATL _IOWR('r', 87, int)
49 #define SIOCADNAT _IOW(r, 80, struct ipnat)
50 #define SIOCRMNAT _IOW(r, 81, struct ipnat)
51 #define SIOCGNATS _IOR(r, 82, struct natstat)
52 #define SIOCGNATL _IOWR(r, 83, struct natlookup)
53 #define SIOCGFRST _IOR(r, 84, struct ipfrstat)
54 #define SIOCGIPST _IOR(r, 85, struct ips_stat)
55 #define SIOCFLNAT _IOWR(r, 86, int)
56 #define SIOCCNATL _IOWR(r, 87, int)
61 #define APR_LABELLEN 16
70 struct in_addr nat_inip
;
71 struct in_addr nat_outip
;
72 struct in_addr nat_oip
; /* other ip */
75 u_short nat_oport
; /* other port */
80 struct ipnat
*nat_ptr
;
82 struct nat
*nat_hnext
[2];
83 struct nat
**nat_hstart
[2];
88 typedef struct ipnat
{
89 struct ipnat
*in_next
;
94 struct in_addr in_nextip
;
98 struct in_addr in_in
[2];
99 struct in_addr in_out
[2];
100 int in_redir
; /* 0 if it's a mapping, 1 if it's a hard redir */
101 char in_ifname
[IFNAMSIZ
];
102 char in_plabel
[APR_LABELLEN
]; /* proxy label */
103 char in_p
; /* protocol */
107 #define in_pmin in_port[0] /* Also holds static redir port */
108 #define in_pmax in_port[1]
109 #define in_nip in_nextip.s_addr
110 #define in_inip in_in[0].s_addr
111 #define in_inmsk in_in[1].s_addr
112 #define in_outip in_out[0].s_addr
113 #define in_outmsk in_out[1].s_addr
115 #define NAT_OUTBOUND 0
116 #define NAT_INBOUND 1
119 #define NAT_REDIRECT 0x02
120 #define NAT_BIMAP (NAT_MAP|NAT_REDIRECT)
122 #define IPN_CMPSIZ (sizeof(struct in_addr) * 4 + sizeof(u_short) * 3 + \
123 sizeof(int) + IFNAMSIZ + APR_LABELLEN + sizeof(char))
125 typedef struct natlookup
{
126 struct in_addr nl_inip
;
127 struct in_addr nl_outip
;
128 struct in_addr nl_realip
;
135 typedef struct natstat
{
150 #define IPN_TCPUDP 0x03
151 #define IPN_DELETE 0x04
152 #define IPN_ICMPERR 0x08
155 typedef struct natlog
{
156 struct in_addr nl_origip
;
157 struct in_addr nl_outip
;
158 struct in_addr nl_inip
;
169 #define NL_NEWMAP NAT_MAP
170 #define NL_NEWRDR NAT_REDIRECT
171 #define NL_EXPIRE 0xffff
174 extern void ip_natsync
__P((void *));
175 extern u_long fr_defnatage
;
176 extern u_long fr_defnaticmpage
;
177 extern nat_t
*nat_table
[2][NAT_SIZE
];
178 #if defined(__NetBSD__) || defined(__OpenBSD__) || (__FreeBSD_version >= 300003)
179 extern int nat_ioctl
__P((caddr_t
, u_long
, int));
181 extern int nat_ioctl
__P((caddr_t
, int, int));
183 extern nat_t
*nat_new
__P((ipnat_t
*, ip_t
*, fr_info_t
*, u_short
, int));
184 extern nat_t
*nat_outlookup
__P((void *, int, struct in_addr
, u_short
,
185 struct in_addr
, u_short
));
186 extern nat_t
*nat_inlookup
__P((void *, int, struct in_addr
, u_short
,
187 struct in_addr
, u_short
));
188 extern nat_t
*nat_lookupredir
__P((natlookup_t
*));
189 extern nat_t
*nat_lookupmapip
__P((void *, int, struct in_addr
, u_short
,
190 struct in_addr
, u_short
));
191 extern nat_t
*nat_icmpinlookup
__P((ip_t
*, fr_info_t
*));
192 extern nat_t
*nat_icmpin
__P((ip_t
*, fr_info_t
*, int *));
194 extern int ip_natout
__P((ip_t
*, int, fr_info_t
*));
195 extern int ip_natin
__P((ip_t
*, int, fr_info_t
*));
196 extern void ip_natunload
__P((void)), ip_natexpire
__P((void));
197 extern void nat_log
__P((struct nat
*, u_short
));
198 extern void fix_incksum
__P((u_short
*, u_32_t
));
199 extern void fix_outcksum
__P((u_short
*, u_32_t
));
201 #endif /* __IP_NAT_H__ */