|
25 | 25 | #include <sys/time.h>
|
26 | 26 | #endif
|
27 | 27 | #include "nsapi_types.h"
|
| 28 | +#include "mbed_retarget.h" |
| 29 | + |
28 | 30 | // Operating System
|
29 | 31 | #define NO_SYS 0
|
30 | 32 |
|
31 |
| -#if MBED_CONF_LWIP_IPV4_ENABLED |
32 |
| -#define LWIP_IPV4 1 |
33 |
| -#else |
34 |
| -#define LWIP_IPV4 0 |
35 |
| -#endif |
36 |
| -#if MBED_CONF_LWIP_IPV6_ENABLED |
37 |
| -#define LWIP_IPV6 1 |
38 |
| -#else |
39 |
| -#define LWIP_IPV6 0 |
40 |
| -#endif |
41 | 33 | #if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
42 | 34 | #error "Either IPv4 or IPv6 must be enabled."
|
43 | 35 | #endif
|
44 | 36 |
|
| 37 | +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED |
| 38 | + |
| 39 | +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED |
| 40 | + |
| 41 | +#define LWIP_PROVIDE_ERRNO 0 |
| 42 | + |
45 | 43 | // On dual stack configuration how long to wait for both or preferred stack
|
46 | 44 | // addresses before completing bring up.
|
47 | 45 | #if LWIP_IPV4 && LWIP_IPV6
|
|
57 | 55 | #define BOTH_ADDR_TIMEOUT 0
|
58 | 56 | #endif
|
59 | 57 |
|
60 |
| -// Configurable DHCP timeout. DHCP timeout can be configured for specific usecase requirement. |
61 |
| -#ifdef MBED_CONF_LWIP_DHCP_TIMEOUT |
62 |
| -#define DHCP_TIMEOUT (MBED_CONF_LWIP_DHCP_TIMEOUT) |
63 |
| -#else |
64 |
| -#define DHCP_TIMEOUT 60 |
65 |
| -#endif |
| 58 | + |
| 59 | +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT |
66 | 60 |
|
67 | 61 | #define LINK_TIMEOUT 60
|
68 | 62 |
|
69 | 63 | #define PREF_IPV4 1
|
70 | 64 | #define PREF_IPV6 2
|
71 | 65 |
|
72 |
| -#if MBED_CONF_LWIP_IP_VER_PREF == 4 |
73 |
| -#define IP_VERSION_PREF PREF_IPV4 |
74 |
| -#endif |
75 | 66 | #if MBED_CONF_LWIP_IP_VER_PREF == 6
|
76 | 67 | #define IP_VERSION_PREF PREF_IPV6
|
77 |
| -#endif |
78 |
| -#ifndef IP_VERSION_PREF |
| 68 | +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 |
| 69 | +#define IP_VERSION_PREF PREF_IPV4 |
| 70 | +#else |
79 | 71 | #error "Either IPv4 or IPv6 must be preferred."
|
80 | 72 | #endif
|
81 | 73 |
|
82 |
| -#undef LWIP_DEBUG |
83 |
| -#if MBED_CONF_LWIP_DEBUG_ENABLED |
84 |
| -#define LWIP_DEBUG 1 |
85 |
| -#endif |
| 74 | +#define LWIP_DEBUG MBED_CONF_LWIP_DEBUG_ENABLED |
86 | 75 |
|
87 | 76 | #if NO_SYS == 0
|
88 | 77 | #include "cmsis_os2.h"
|
|
102 | 91 | // Thread stacks use 8-byte alignment
|
103 | 92 | #define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
|
104 | 93 |
|
105 |
| -// Thread stack size for lwip tcpip thread |
106 |
| -#ifndef MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE |
107 |
| -#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 |
108 |
| -#endif |
109 |
| - |
110 | 94 | #ifdef LWIP_DEBUG
|
111 | 95 | // For LWIP debug, double the stack
|
112 | 96 | #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8)
|
|
120 | 104 | // Thread priority (osPriorityNormal by default)
|
121 | 105 | #define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY)
|
122 | 106 |
|
123 |
| -// Thread stack size for lwip system threads |
124 |
| -#ifndef MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE |
125 |
| -#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 |
126 |
| -#endif |
127 |
| - |
128 | 107 | #ifdef LWIP_DEBUG
|
129 | 108 | #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8)
|
130 | 109 | #else
|
|
143 | 122 | #define LWIP_RAM_HEAP_POINTER lwip_ram_heap
|
144 | 123 |
|
145 | 124 | // Number of simultaneously queued TCP segments.
|
146 |
| -#ifdef MBED_CONF_LWIP_MEMP_NUM_TCP_SEG |
147 | 125 | #define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG
|
148 |
| -#endif |
149 | 126 |
|
150 | 127 | // TCP Maximum segment size.
|
151 |
| -#ifdef MBED_CONF_LWIP_TCP_MSS |
152 | 128 | #define TCP_MSS MBED_CONF_LWIP_TCP_MSS
|
153 |
| -#endif |
154 | 129 |
|
155 | 130 | // TCP sender buffer space (bytes).
|
156 |
| -#ifdef MBED_CONF_LWIP_TCP_SND_BUF |
157 | 131 | #define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF
|
158 |
| -#endif |
159 | 132 |
|
160 | 133 | // TCP sender buffer space (bytes).
|
161 |
| -#ifdef MBED_CONF_LWIP_TCP_WND |
162 | 134 | #define TCP_WND MBED_CONF_LWIP_TCP_WND
|
163 |
| -#endif |
164 | 135 |
|
165 |
| -#ifdef MBED_CONF_LWIP_TCP_MAXRTX |
166 | 136 | #define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX
|
167 |
| -#endif |
168 | 137 |
|
169 |
| -#ifdef MBED_CONF_LWIP_TCP_SYNMAXRTX |
170 | 138 | #define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX
|
171 |
| -#endif |
172 | 139 |
|
173 | 140 | // Number of pool pbufs.
|
174 | 141 | // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS)
|
175 |
| -#ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE |
176 |
| -#undef PBUF_POOL_SIZE |
177 | 142 | #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE
|
178 |
| -#else |
179 |
| -#ifndef PBUF_POOL_SIZE |
180 |
| -#define PBUF_POOL_SIZE 5 |
181 |
| -#endif |
182 |
| -#endif |
183 | 143 |
|
184 | 144 | #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE
|
185 | 145 | #undef PBUF_POOL_BUFSIZE
|
|
194 | 154 | #endif
|
195 | 155 | #endif
|
196 | 156 |
|
197 |
| -#ifdef MBED_CONF_LWIP_MEM_SIZE |
198 |
| -#undef MEM_SIZE |
199 | 157 | #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE
|
200 |
| -#endif |
201 | 158 |
|
202 | 159 | // One tcp_pcb_listen is needed for each TCPServer.
|
203 | 160 | // Each requires 72 bytes of RAM.
|
204 |
| -#ifdef MBED_CONF_LWIP_TCP_SERVER_MAX |
205 | 161 | #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX
|
206 |
| -#else |
207 |
| -#define MEMP_NUM_TCP_PCB_LISTEN 4 |
208 |
| -#endif |
209 | 162 |
|
210 | 163 | // One is tcp_pcb needed for each TCPSocket.
|
211 | 164 | // Each requires 196 bytes of RAM.
|
212 |
| -#ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX |
213 | 165 | #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX
|
214 |
| -#else |
215 |
| -#define MEMP_NUM_TCP_PCB 4 |
216 |
| -#endif |
217 | 166 |
|
218 | 167 | // One udp_pcb is needed for each UDPSocket.
|
219 | 168 | // Each requires 84 bytes of RAM (total rounded to multiple of 512).
|
220 |
| -#ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX |
221 | 169 | #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX
|
222 |
| -#else |
223 |
| -#define MEMP_NUM_UDP_PCB 4 |
224 |
| -#endif |
225 | 170 |
|
226 | 171 | // Number of non-pool pbufs.
|
227 | 172 | // Each requires 92 bytes of RAM.
|
228 |
| -#ifndef MEMP_NUM_PBUF |
229 |
| -#define MEMP_NUM_PBUF 8 |
230 |
| -#endif |
| 173 | +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF |
231 | 174 |
|
232 | 175 | // Each netbuf requires 64 bytes of RAM.
|
233 |
| -#ifndef MEMP_NUM_NETBUF |
234 |
| -#define MEMP_NUM_NETBUF 8 |
235 |
| -#endif |
| 176 | +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF |
236 | 177 |
|
237 | 178 | // One netconn is needed for each UDPSocket, TCPSocket or TCPServer.
|
238 | 179 | // Each requires 236 bytes of RAM (total rounded to multiple of 512).
|
239 |
| -#ifdef MBED_CONF_LWIP_SOCKET_MAX |
240 | 180 | #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX
|
241 |
| -#else |
242 |
| -#define MEMP_NUM_NETCONN 4 |
243 |
| -#endif |
244 | 181 |
|
245 | 182 | #if MBED_CONF_LWIP_TCP_ENABLED
|
246 | 183 | #define LWIP_TCP 1
|
247 | 184 | #define TCP_OVERSIZE 0
|
248 | 185 | #define LWIP_TCP_KEEPALIVE 1
|
249 |
| -#ifdef MBED_CONF_TCP_CLOSE_TIMEOUT |
250 |
| -#define TCP_CLOSE_TIMEOUT MBED_CONF_TCP_CLOSE_TIMEOUT |
251 |
| -#else |
252 |
| -#define TCP_CLOSE_TIMEOUT 1000 |
253 |
| -#endif |
| 186 | + |
| 187 | +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT |
| 188 | + |
254 | 189 | #else
|
255 | 190 | #define LWIP_TCP 0
|
256 | 191 | #endif
|
|
0 commit comments