lwipopts.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  2. * Copyright (c) 2025, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef LWIPOPTS_H
  7. #define LWIPOPTS_H
  8. #ifdef USE_LWIPOPTS_APP_H
  9. #include "lwipopts_app.h"
  10. #endif
  11. /**
  12. * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
  13. * critical regions during buffer allocation, deallocation and memory
  14. * allocation and deallocation.
  15. */
  16. #define SYS_LIGHTWEIGHT_PROT 1
  17. #define IP_REASSEMBLY 0
  18. #define IP_FRAG 0
  19. #define ARP_QUEUEING 0
  20. #define NO_SYS 0
  21. #define LWIP_RAND rand
  22. #define LWIP_NETIF_HOSTNAME 0
  23. #define LWIP_TIMEVAL_PRIVATE 0
  24. #define LWIP_TIMERS 1
  25. #define LWIP_RAW 1
  26. #define LWIP_IPV4 1
  27. #define LWIP_IGMP 1
  28. #define LWIP_ICMP 1
  29. #define ICMP_TTL 64
  30. #define LWIP_TCP 1
  31. #define TCP_TTL 255
  32. #define LWIP_UDP 1
  33. #define UDP_TTL 255
  34. #define LWIP_DNS 1
  35. /**
  36. * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
  37. */
  38. #define LWIP_NETIF_API 1
  39. /**
  40. * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
  41. */
  42. #define LWIP_NETCONN 1
  43. /**
  44. * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
  45. */
  46. #define LWIP_SOCKET 1
  47. /* ---------- Memory options ---------- */
  48. #define MEMP_MEM_MALLOC 0
  49. /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
  50. lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
  51. byte alignment -> define MEM_ALIGNMENT to 2. */
  52. #ifndef MEM_ALIGNMENT
  53. #define MEM_ALIGNMENT 64
  54. #endif
  55. /* MEM_SIZE: the size of the heap memory. If the application will send
  56. a lot of data that needs to be copied, this should be set high. */
  57. #ifndef MEM_SIZE
  58. #define MEM_SIZE (32 * 1024)
  59. #endif
  60. /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
  61. sends a lot of data out of ROM (or other static memory), this
  62. should be set high. */
  63. #ifndef MEMP_NUM_PBUF
  64. #define MEMP_NUM_PBUF 100
  65. #endif
  66. /**
  67. * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
  68. * (requires the LWIP_RAW option)
  69. */
  70. #ifndef MEMP_NUM_RAW_PCB
  71. #define MEMP_NUM_RAW_PCB 4
  72. #endif
  73. /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
  74. per active UDP "connection". */
  75. #ifndef MEMP_NUM_UDP_PCB
  76. #define MEMP_NUM_UDP_PCB 4
  77. #endif
  78. /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
  79. connections. */
  80. #ifndef MEMP_NUM_TCP_PCB
  81. #define MEMP_NUM_TCP_PCB 4
  82. #endif
  83. /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
  84. connections. */
  85. #ifndef MEMP_NUM_TCP_PCB_LISTEN
  86. #define MEMP_NUM_TCP_PCB_LISTEN 5
  87. #endif
  88. /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
  89. segments. */
  90. #ifndef MEMP_NUM_TCP_SEG
  91. #define MEMP_NUM_TCP_SEG 40
  92. #endif
  93. /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
  94. timeouts. */
  95. #ifndef MEMP_NUM_SYS_TIMEOUT
  96. #define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL)
  97. #endif
  98. /**
  99. * MEMP_NUM_NETCONN: the number of struct netconns.
  100. * (only needed if you use the sequential API, like api_lib.c)
  101. */
  102. #ifndef MEMP_NUM_NETCONN
  103. #define MEMP_NUM_NETCONN 4
  104. #endif
  105. /* ---------- Pbuf options ---------- */
  106. /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
  107. #ifndef PBUF_POOL_SIZE
  108. #define PBUF_POOL_SIZE 20
  109. #endif
  110. /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
  111. #ifndef PBUF_POOL_BUFSIZE
  112. #define PBUF_POOL_BUFSIZE 1600
  113. #endif
  114. /* ---------- TCP options ---------- */
  115. /* Controls if TCP should queue segments that arrive out of
  116. order. Define to 0 if your device is low on memory. */
  117. #ifndef TCP_QUEUE_OOSEQ
  118. #define TCP_QUEUE_OOSEQ 0
  119. #endif
  120. /* TCP Maximum segment size. */
  121. #ifndef TCP_MSS
  122. #define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
  123. #endif
  124. /* TCP sender buffer space (bytes). */
  125. #ifndef TCP_SND_BUF
  126. #define TCP_SND_BUF (8 * TCP_MSS)
  127. #endif
  128. /* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
  129. as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
  130. #ifndef TCP_SND_QUEUELEN
  131. #define TCP_SND_QUEUELEN (4 * TCP_SND_BUF / TCP_MSS)
  132. #endif
  133. /* TCP receive window. */
  134. #ifndef TCP_WND
  135. #define TCP_WND (16 * TCP_MSS)
  136. #endif
  137. /* ---------- DHCP options ---------- */
  138. /* Define LWIP_DHCP to 1 if you want DHCP configuration of
  139. interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
  140. turning this on does currently not work. */
  141. #ifndef LWIP_DHCP
  142. #define LWIP_DHCP 1
  143. #endif
  144. /* ---------- Statistics options ---------- */
  145. #ifndef LWIP_STATS
  146. #define LWIP_STATS 0
  147. #endif
  148. #ifndef LWIP_PROVIDE_ERRNO
  149. #define LWIP_PROVIDE_ERRNO 1
  150. #endif
  151. /*
  152. ------------------------------------------------
  153. ---------- Network Interfaces options ----------
  154. ------------------------------------------------
  155. */
  156. /**
  157. * LWIP_SINGLE_NETIF==1: use a single netif only. This is the common case for
  158. * small real-life targets. Some code like routing etc. can be left out.
  159. */
  160. #ifndef LWIP_SINGLE_NETIF
  161. #define LWIP_SINGLE_NETIF 1
  162. #endif
  163. /* ---------- link callback options ---------- */
  164. /* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
  165. * whenever the link changes (i.e., link down)
  166. */
  167. #ifndef LWIP_NETIF_LINK_CALLBACK
  168. #define LWIP_NETIF_LINK_CALLBACK 1
  169. #endif
  170. /**
  171. * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP *tries* to put all data
  172. * to be sent into one single pbuf. This is for compatibility with DMA-enabled
  173. * MACs that do not support scatter-gather.
  174. * Beware that this might involve CPU-memcpy before transmitting that would not
  175. * be needed without this flag! Use this only if you need to!
  176. *
  177. * ATTENTION: a driver should *NOT* rely on getting single pbufs but check TX
  178. * pbufs for being in one piece. If not, @ref pbuf_clone can be used to get
  179. * a single pbuf:
  180. * if (p->next != NULL) {
  181. * struct pbuf *q = pbuf_clone(PBUF_RAW, PBUF_RAM, p);
  182. * if (q == NULL) {
  183. * return ERR_MEM;
  184. * }
  185. * p = q; ATTENTION: do NOT free the old 'p' as the ref belongs to the caller!
  186. * }
  187. */
  188. #ifndef LWIP_NETIF_TX_SINGLE_PBUF
  189. #define LWIP_NETIF_TX_SINGLE_PBUF 0
  190. #endif
  191. /*
  192. --------------------------------------
  193. ---------- Checksum options ----------
  194. --------------------------------------
  195. */
  196. /*
  197. * Some MCUs allow computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
  198. * To use this feature let the following define uncommented.
  199. * To disable it and process by CPU comment the the checksum.
  200. */
  201. #ifdef CHECKSUM_BY_HARDWARE
  202. /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
  203. #define CHECKSUM_GEN_IP 0
  204. /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
  205. #define CHECKSUM_GEN_UDP 0
  206. /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
  207. #define CHECKSUM_GEN_TCP 0
  208. /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
  209. #define CHECKSUM_CHECK_IP 0
  210. /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
  211. #define CHECKSUM_CHECK_UDP 0
  212. /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
  213. #define CHECKSUM_CHECK_TCP 0
  214. /* CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/
  215. #define CHECKSUM_GEN_ICMP 0
  216. #else
  217. /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
  218. #define CHECKSUM_GEN_IP 1
  219. /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
  220. #define CHECKSUM_GEN_UDP 1
  221. /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
  222. #define CHECKSUM_GEN_TCP 1
  223. /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
  224. #define CHECKSUM_CHECK_IP 1
  225. /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
  226. #define CHECKSUM_CHECK_UDP 1
  227. /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
  228. #define CHECKSUM_CHECK_TCP 1
  229. /* CHECKSUM_CHECK_ICMP==1: Check checksums by software for incoming ICMP packets.*/
  230. #define CHECKSUM_GEN_ICMP 1
  231. #endif
  232. /*
  233. -----------------------------------
  234. ---------- DEBUG options ----------
  235. -----------------------------------
  236. */
  237. #ifdef LWIP_DEBUG
  238. #ifndef LWIP_DBG_MIN_LEVEL
  239. #define LWIP_DBG_MIN_LEVEL 0
  240. #endif
  241. #ifndef PPP_DEBUG
  242. #define PPP_DEBUG LWIP_DBG_OFF
  243. #endif
  244. #ifndef MEM_DEBUG
  245. #define MEM_DEBUG LWIP_DBG_OFF
  246. #endif
  247. #ifndef MEMP_DEBUG
  248. #define MEMP_DEBUG LWIP_DBG_OFF
  249. #endif
  250. #ifndef PBUF_DEBUG
  251. #define PBUF_DEBUG LWIP_DBG_OFF
  252. #endif
  253. #ifndef API_LIB_DEBUG
  254. #define API_LIB_DEBUG LWIP_DBG_OFF
  255. #endif
  256. #ifndef API_MSG_DEBUG
  257. #define API_MSG_DEBUG LWIP_DBG_OFF
  258. #endif
  259. #ifndef TCPIP_DEBUG
  260. #define TCPIP_DEBUG LWIP_DBG_OFF
  261. #endif
  262. #ifndef NETIF_DEBUG
  263. #define NETIF_DEBUG LWIP_DBG_OFF
  264. #endif
  265. #ifndef SOCKETS_DEBUG
  266. #define SOCKETS_DEBUG LWIP_DBG_OFF
  267. #endif
  268. #ifndef DNS_DEBUG
  269. #define DNS_DEBUG LWIP_DBG_OFF
  270. #endif
  271. #ifndef AUTOIP_DEBUG
  272. #define AUTOIP_DEBUG LWIP_DBG_OFF
  273. #endif
  274. #ifndef DHCP_DEBUG
  275. #define DHCP_DEBUG LWIP_DBG_OFF
  276. #endif
  277. #ifndef IP_DEBUG
  278. #define IP_DEBUG LWIP_DBG_OFF
  279. #endif
  280. #ifndef IP_REASS_DEBUG
  281. #define IP_REASS_DEBUG LWIP_DBG_OFF
  282. #endif
  283. #ifndef ICMP_DEBUG
  284. #define ICMP_DEBUG LWIP_DBG_OFF
  285. #endif
  286. #ifndef IGMP_DEBUG
  287. #define IGMP_DEBUG LWIP_DBG_OFF
  288. #endif
  289. #ifndef UDP_DEBUG
  290. #define UDP_DEBUG LWIP_DBG_OFF
  291. #endif
  292. #ifndef TCP_DEBUG
  293. #define TCP_DEBUG LWIP_DBG_OFF
  294. #endif
  295. #ifndef TCP_INPUT_DEBUG
  296. #define TCP_INPUT_DEBUG LWIP_DBG_OFF
  297. #endif
  298. #ifndef TCP_OUTPUT_DEBUG
  299. #define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
  300. #endif
  301. #ifndef TCP_RTO_DEBUG
  302. #define TCP_RTO_DEBUG LWIP_DBG_OFF
  303. #endif
  304. #ifndef TCP_CWND_DEBUG
  305. #define TCP_CWND_DEBUG LWIP_DBG_OFF
  306. #endif
  307. #ifndef TCP_WND_DEBUG
  308. #define TCP_WND_DEBUG LWIP_DBG_OFF
  309. #endif
  310. #ifndef TCP_FR_DEBUG
  311. #define TCP_FR_DEBUG LWIP_DBG_OFF
  312. #endif
  313. #ifndef TCP_QLEN_DEBUG
  314. #define TCP_QLEN_DEBUG LWIP_DBG_OFF
  315. #endif
  316. #ifndef TCP_RST_DEBUG
  317. #define TCP_RST_DEBUG LWIP_DBG_OFF
  318. #endif
  319. #ifndef ETHARP_DEBUG
  320. #define ETHARP_DEBUG LWIP_DBG_OFF
  321. #endif
  322. #endif
  323. /*
  324. ---------------------------------
  325. ---------- OS options ----------
  326. ---------------------------------
  327. */
  328. #ifndef TCPIP_THREAD_NAME
  329. #define TCPIP_THREAD_NAME "tcpip"
  330. #endif
  331. #ifndef TCPIP_THREAD_STACKSIZE
  332. #define TCPIP_THREAD_STACKSIZE 2048
  333. #endif
  334. #ifndef TCPIP_MBOX_SIZE
  335. #define TCPIP_MBOX_SIZE 8
  336. #endif
  337. #ifndef DEFAULT_RAW_RECVMBOX_SIZE
  338. #define DEFAULT_RAW_RECVMBOX_SIZE 50
  339. #endif
  340. #ifndef DEFAULT_UDP_RECVMBOX_SIZE
  341. #define DEFAULT_UDP_RECVMBOX_SIZE 50
  342. #endif
  343. #ifndef DEFAULT_TCP_RECVMBOX_SIZE
  344. #define DEFAULT_TCP_RECVMBOX_SIZE 50
  345. #endif
  346. #ifndef DEFAULT_ACCEPTMBOX_SIZE
  347. #define DEFAULT_ACCEPTMBOX_SIZE 50
  348. #endif
  349. #ifndef DEFAULT_THREAD_STACKSIZE
  350. #define DEFAULT_THREAD_STACKSIZE 500
  351. #endif
  352. #ifndef TCPIP_THREAD_PRIO
  353. #define TCPIP_THREAD_PRIO 10
  354. #endif
  355. #define LWIP_COMPAT_MUTEX 0
  356. #define LWIP_TCPIP_CORE_LOCKING 1
  357. #ifndef LWIP_TCPIP_CORE_LOCKING_INPUT
  358. #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
  359. #endif
  360. #ifndef LWIP_MEM_SECTION
  361. #define LWIP_MEM_SECTION ".bss"
  362. #endif
  363. #endif /* __LWIPOPTS_H__ */