1 | #ifndef _VBOX_NETNAT_LWIP_OPTS_H_
|
---|
2 | #define _VBOX_NETNAT_LWIP_OPTS_H_
|
---|
3 |
|
---|
4 | #include <iprt/mem.h>
|
---|
5 | #include <iprt/alloca.h> /* This may include malloc.h (msc), which is something that has
|
---|
6 | * to be done before redefining any of the functions therein. */
|
---|
7 | #include <iprt/rand.h> /* see LWIP_RAND() definition */
|
---|
8 |
|
---|
9 | /* lwip/sockets.h assumes that if FD_SET is defined (in case of Innotek GCC
|
---|
10 | * its definition is dragged through iprt/types.h) then struct timeval is
|
---|
11 | * defined as well, but it's not the case. So include it manually. */
|
---|
12 | #ifdef RT_OS_OS2
|
---|
13 | # include <sys/time.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | /** Make lwIP use the libc malloc, or more precisely (see below) the IPRT
|
---|
17 | * memory allocation functions. */
|
---|
18 | #define MEM_LIBC_MALLOC 1
|
---|
19 |
|
---|
20 | /** Set proper memory alignment. */
|
---|
21 | #if HC_ARCH_BITS == 64
|
---|
22 | # define MEM_ALIGNMENT 8
|
---|
23 | #else
|
---|
24 | #define MEM_ALIGNMENT 4
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | /* Padding before Ethernet header to make IP header aligned */
|
---|
28 | #define ETH_PAD_SIZE 2
|
---|
29 |
|
---|
30 | /* IP */
|
---|
31 | #define IP_REASSEMBLY 1
|
---|
32 | #define IP_REASS_MAX_PBUFS 128
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | /** Increase maximum TCP window size. */
|
---|
37 | #define TCP_WND 32768
|
---|
38 |
|
---|
39 | /** Increase TCP maximum segment size. */
|
---|
40 | #define TCP_MSS 1460
|
---|
41 |
|
---|
42 | /** Enable queueing of out-of-order segments. */
|
---|
43 | #define TCP_QUEUE_OOSEQ 1
|
---|
44 |
|
---|
45 | /** TCP sender buffer space (bytes). */
|
---|
46 | #define TCP_SND_BUF (32 * TCP_MSS)
|
---|
47 |
|
---|
48 | /* TCP sender buffer space (pbufs). This must be at least = 2 *
|
---|
49 | TCP_SND_BUF/TCP_MSS for things to work. */
|
---|
50 | #define TCP_SND_QUEUELEN 128
|
---|
51 |
|
---|
52 | /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
---|
53 | sends a lot of data out of ROM (or other static memory), this
|
---|
54 | should be set high.
|
---|
55 |
|
---|
56 | NB: This is for PBUF_ROM and PBUF_REF pbufs only!
|
---|
57 |
|
---|
58 | Number of PBUF_POOL pbufs is controlled by PBUF_POOL_SIZE that,
|
---|
59 | somewhat confusingly, breaks MEMP_NUM_* pattern.
|
---|
60 |
|
---|
61 | PBUF_RAM pbufs are allocated with mem_malloc (with MEM_LIBC_MALLOC
|
---|
62 | set to 1 this is just system malloc), not memp_malloc. */
|
---|
63 | #define MEMP_NUM_PBUF (1024 * 4)
|
---|
64 |
|
---|
65 |
|
---|
66 | /* MEMP_NUM_MLD6_GROUP: Maximum number of IPv6 multicast groups that
|
---|
67 | can be joined.
|
---|
68 |
|
---|
69 | We need to be able to join solicited node multicast for each
|
---|
70 | address (potentially different) and two groups for DHCP6. All
|
---|
71 | routers multicast is hardcoded in ip6.c and does not require
|
---|
72 | explicit joining. Provide also for a few extra groups just in
|
---|
73 | case. */
|
---|
74 | #define MEMP_NUM_MLD6_GROUP (LWIP_IPV6_NUM_ADDRESSES + /* dhcp6 */ 2 + /* extra */ 8)
|
---|
75 |
|
---|
76 |
|
---|
77 | /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
---|
78 | segments. */
|
---|
79 | #define MEMP_NUM_TCP_SEG (MEMP_NUM_TCP_PCB * TCP_SND_QUEUELEN / 2)
|
---|
80 |
|
---|
81 | /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
---|
82 | connections. */
|
---|
83 | #define MEMP_NUM_TCP_PCB 128
|
---|
84 |
|
---|
85 | /* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
|
---|
86 | for sequential API communication and incoming packets. Used in
|
---|
87 | src/api/tcpip.c. */
|
---|
88 | #define MEMP_NUM_TCPIP_MSG_API 128
|
---|
89 | #define MEMP_NUM_TCPIP_MSG_INPKT 1024
|
---|
90 |
|
---|
91 | /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
---|
92 | per active UDP "connection". */
|
---|
93 | #define MEMP_NUM_UDP_PCB 32
|
---|
94 |
|
---|
95 | /* Pbuf options */
|
---|
96 | /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
|
---|
97 | This is only for PBUF_POOL pbufs, primarily used by netif drivers.
|
---|
98 |
|
---|
99 | This should have been named with the MEMP_NUM_ prefix (cf.
|
---|
100 | MEMP_NUM_PBUF for PBUF_ROM and PBUF_REF) as it controls the size of
|
---|
101 | yet another memp_malloc() pool. */
|
---|
102 | #define PBUF_POOL_SIZE (1024 * 4)
|
---|
103 |
|
---|
104 | /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool.
|
---|
105 | Use default that is based on TCP_MSS and PBUF_LINK_HLEN. */
|
---|
106 | #undef PBUF_POOL_BUFSIZE
|
---|
107 |
|
---|
108 | /** Turn on support for lightweight critical region protection. Leaving this
|
---|
109 | * off uses synchronization code in pbuf.c which is totally polluted with
|
---|
110 | * races. All the other lwip source files would fall back to semaphore-based
|
---|
111 | * synchronization, but pbuf.c is just broken, leading to incorrect allocation
|
---|
112 | * and as a result to assertions due to buffers being double freed. */
|
---|
113 | #define SYS_LIGHTWEIGHT_PROT 1
|
---|
114 |
|
---|
115 | /** Attempt to get rid of htons etc. macro issues. */
|
---|
116 | #undef LWIP_PREFIX_BYTEORDER_FUNCS
|
---|
117 |
|
---|
118 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 0
|
---|
119 | #define LWIP_TCPIP_CORE_LOCKING 0
|
---|
120 | #define LWIP_TCP 1
|
---|
121 | #define LWIP_SOCKET 0
|
---|
122 | #define LWIP_ARP 1
|
---|
123 | #define ARP_PROXY 1
|
---|
124 | #define LWIP_ETHERNET 1
|
---|
125 | #define LWIP_COMPAT_SOCKETS 0
|
---|
126 | #define LWIP_COMPAT_MUTEX 1
|
---|
127 |
|
---|
128 | #define LWIP_IPV6 1
|
---|
129 | #define LWIP_IPV6_FORWARD 1
|
---|
130 | #define LWIP_ND6_PROXY 1
|
---|
131 |
|
---|
132 | #define LWIP_ND6_ALLOW_RA_UPDATES (!LWIP_IPV6_FORWARD)
|
---|
133 | #define LWIP_IPV6_SEND_ROUTER_SOLICIT (!LWIP_IPV6_FORWARD)
|
---|
134 | /* IPv6 autoconfig we don't need in proxy, but it required for very seldom cases
|
---|
135 | * iSCSI over intnet with IPv6
|
---|
136 | */
|
---|
137 | #define LWIP_IPV6_AUTOCONFIG 1
|
---|
138 | #if LWIP_IPV6_FORWARD /* otherwise use the default from lwip/opt.h */
|
---|
139 | #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
|
---|
140 | #endif
|
---|
141 |
|
---|
142 | #define LWIP_IPV6_FRAG 1
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * aka Slirp mode.
|
---|
146 | */
|
---|
147 | #define LWIP_CONNECTION_PROXY 1
|
---|
148 | #define IP_FORWARD 1
|
---|
149 |
|
---|
150 | /* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active
|
---|
151 | timeouts. */
|
---|
152 | #define MEMP_NUM_SYS_TIMEOUT 16
|
---|
153 |
|
---|
154 |
|
---|
155 | /* this is required for IPv6 and IGMP needs */
|
---|
156 | #define LWIP_RAND() RTRandU32()
|
---|
157 |
|
---|
158 | /* Debugging stuff. */
|
---|
159 | #ifdef DEBUG
|
---|
160 | # define LWIP_DEBUG
|
---|
161 | # include "lwip-log.h"
|
---|
162 |
|
---|
163 | # define LWIP_PROXY_DEBUG LWIP_DBG_OFF
|
---|
164 | #endif /* DEBUG */
|
---|
165 |
|
---|
166 | /* printf formatter definitions */
|
---|
167 | #define U16_F "hu"
|
---|
168 | #define S16_F "hd"
|
---|
169 | #define X16_F "hx"
|
---|
170 | #define U32_F "lu"
|
---|
171 | #define S32_F "ld"
|
---|
172 | #define X32_F "lx"
|
---|
173 |
|
---|
174 | /* Redirect libc memory alloc functions to IPRT. */
|
---|
175 | #define malloc(x) RTMemAlloc(x)
|
---|
176 | #define realloc(x,y) RTMemRealloc((x), (y))
|
---|
177 | #define free(x) RTMemFree(x)
|
---|
178 |
|
---|
179 | #endif /* _VBOX_NETNAT_LWIP_OPTS_H_ */
|
---|