]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netinet6/natpt_defs.h
39fa41c4f88bc005a1eeded41399107c29716401
1 /* $KAME: natpt_defs.h,v 1.7 2000/03/25 07:23:54 sumikawa Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #define NATPT_MAXHASH (397)
35 #define MAXTSLOTENTRY (4096)
37 #define SZSIN6 sizeof(struct sockaddr_in6)
38 #define SZSIN sizeof(struct sockaddr_in)
40 #define CAR(p) ((p)->car)
41 #define CDR(p) ((p)->cdr)
42 #define CAAR(p) (CAR(CAR(p)))
43 #define CADR(p) (CAR(CDR(p)))
44 #define CDAR(p) (CDR(CAR(p)))
45 #define CDDR(p) (CDR(CDR(p)))
48 #define tcp6hdr tcphdr
52 #if defined(NATPT_ASSERT) && (NATPT_ASSERT != 0)
53 # if defined(__STDC__)
54 # define ASSERT(e) ((e) ? (void)0 : natpt_assert(__FILE__, __LINE__, #e))
56 # define ASSERT(e) ((e) ? (void)0 : natpt_assert(__FILE__, __LINE__, "e"))
60 # define ASSERT(e) ((void)0)
64 #define IN4_ARE_ADDR_EQUAL(a, b) \
65 ((a)->s_addr == (b)->s_addr)
68 #define ReturnEnobufs(m) if (m == NULL) { errno = ENOBUFS; return (NULL); }
71 #if (defined(KERNEL)) || (defined(_KERNEL))
73 #define isDebug(d) (natpt_debug & (d))
74 #define isDump(d) (natpt_dump & (d))
76 #define D_DIVEIN4 0x00000001
77 #define D_PEEKOUTGOINGV4 0x00000002
78 #define D_TRANSLATINGIPV4 0x00000010
79 #define D_TRANSLATEDIPV4 0x00001000
81 #define D_DIVEIN6 0x00010000
82 #define D_IN6REJECT 0x00020000
83 #define D_IN6ACCEPT 0x00040000
84 #define D_PEEKOUTGOINGV6 0x00080000
85 #define D_TRANSLATINGIPV6 0x00100000
86 #define D_TRANSLATEDIPV6 0x01000000
88 #define fixSuMiReICMPBug (1)
90 #ifdef fixSuMiReICMPBug
91 #define IPDST (0xc48db2cb) /* == 203.178.141.196 XXX */
92 #define ICMPSRC (0x02c410ac) /* == 172.16.196.2 XXX */
95 #endif /* defined(KERNEL) */
103 #if defined(__FreeBSD__) && __FreeBSD__ >= 3 || defined (__APPLE__)
104 #define rcb_list list
109 * Macros for type conversion
110 * dtom(x) - convert data pointer within mbuf to mbuf pointer (XXX)
112 #define dtom(x) ((struct mbuf *)((long)(x) & ~(MSIZE-1)))
119 * Structure definitions.
129 /* Interface Box structure */
137 char ifName
[IFNAMSIZ
];
144 struct _cv
/* 28[byte] */
146 u_char ip_p
; /* IPPROTO_(ICMP[46]|TCP|UDP) */
147 u_char ip_payload
; /* IPPROTO_(ICMP|TCP|UDP) */
150 /* #define NATPT_UNSPEC (0) */
151 /* #define NATPT_INBOUND (1) */
152 /* #define NATPT_OUTBOUND (2) */
155 #define NATPT_TRACEROUTE (0x01)
156 #define NATPT_NEEDFRAGMENT (0x02)
158 int poff
; /* payload offset */
159 int plen
; /* payload length */
166 struct ip6_hdr
*_ip6
;
172 struct icmp6_hdr
*_icmp6
;
173 struct tcphdr
*_tcp4
;
174 struct tcp6hdr
*_tcp6
;
180 /* IP address structure */
182 union inaddr
/* sizeof(): 16[byte] */
189 struct pAddr
/* sizeof(): 44[byte] */
191 u_char ip_p
; /* protocol family (within struct _tSlot) */
192 u_char sa_family
; /* address family (within struct _cSlot) */
195 #define _port0 port[0]
196 #define _port1 port[1]
198 #define _sport port[0]
199 #define _dport port[1]
200 #define _eport port[1]
202 union inaddr addr
[2];
204 #define in4src addr[0].in4
205 #define in4dst addr[1].in4
206 #define in4Addr addr[0].in4
207 #define in4Mask addr[1].in4
208 #define in4RangeStart addr[0].in4
209 #define in4RangeEnd addr[1].in4
211 #define in6src addr[0].in6
212 #define in6dst addr[1].in6
213 #define in6Addr addr[0].in6
214 #define in6Mask addr[1].in6
220 #define ADDR_SINGLE (1)
221 #define ADDR_MASK (2)
222 #define ADDR_RANGE (3)
223 #define ADDR_FAITH (4)
230 /* Configuration slot entry */
232 struct _cSlot
/* sizeof(): 100[byte] */
235 #define NATPT_STATIC (1) /* Rule was set statically */
236 #define NATPT_DYNAMIC (2) /* Rule was set dynamically */
237 #define NATPT_FAITH (3)
240 #define NATPT_UNSPEC (0)
241 #define NATPT_INBOUND (1)
242 #define NATPT_OUTBOUND (2)
245 #define NATPT_PORT_MAP (0x01) /* Mapping dest port */
246 #define NATPT_PORT_MAP_DYNAMIC (0x02) /* Mapping dest port dynamically */
247 #define NATPT_ADDR_MAP (0x04) /* Mapping dest addr */
248 #define NATPT_ADDR_MAP_DYNAMIC (0x08) /* Mapping dest addr dynamically */
253 u_short cport
; /* current port */
255 struct pAddr local
, remote
;
256 struct _cSlotAux
*aux
; /* place holder */
261 /* Configuration slot auxiliary entry */
262 /* currently not used */
264 struct _cSlotAux
/* sizeof(): 0[byte] */
270 /* Translation slot entry */
272 struct _tSlot
/* sizeof(): 104[byte] */
277 /* #define NATPT_UNSPEC (0) */
278 /* #define NATPT_INBOUND (1) */
279 /* #define NATPT_OUTBOUND (2) */
282 /* #define NATPT_PORT_REMAP (0x01) */
283 /* #define NATPT_ADDR_REMAP (0x02) */
285 /* #define NATPT_STATIC (0x1) */
286 /* #define NATPT_DYNAMIC (0x2) */
287 /* #define NATPT_FAITH (0x3) */
301 struct _tcpstate
*tcp
;
306 struct _tcpstate
/* sizeof(): 28[byte] */
310 u_long _ip_id
[2]; /* IP packet Identification */
311 /* [0]: current packet */
312 /* [1]: just before packet */
313 u_short _port
[2]; /* [0]:outGoing srcPort, [1]:inComing dstPort */
314 /* u_long _iss; initial send sequence number */
315 u_long _delta
[3]; /* Sequence delta */
316 /* [0]: current (cumulative) */
317 /* [1]: just before (cumulative) */
318 /* [2]: (this time) */