lwipopts.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  2. * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  19. * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  20. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  21. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  24. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  25. * OF SUCH DAMAGE.
  26. *
  27. * This file is part of the lwIP TCP/IP stack.
  28. *
  29. * Author: Simon Goldschmidt
  30. *
  31. */
  32. #ifndef LWIP_HDR_LWIPOPTS_H
  33. #define LWIP_HDR_LWIPOPTS_H
  34. #include "stdlib.h"
  35. #include "net_config.h"
  36. #include "lwipports.h"
  37. #if defined (CONFIG_MBEDTLS_LIB_SUPPORT)
  38. #include "mbedtls_config.h"
  39. #endif
  40. #include "quec_proj_config.h"
  41. #include "quec_proj_config_at.h"
  42. #ifdef CONFIG_NET_LWIP_IPV4_ON
  43. #define LWIP_IPV4_ON
  44. #endif
  45. #ifdef CONFIG_NET_LWIP_IPV6_ON
  46. #define LWIP_IPV6_ON
  47. #endif
  48. #ifdef CONFIG_NET_LWIP_RFACK_ON
  49. #define LWIP_RFACK 1
  50. #else
  51. #define LWIP_RFACK 0
  52. #endif
  53. #ifdef LWIP_IPV6_ON
  54. #define LWIP_IPV6 1
  55. #define LWIP_IPV6_FRAG 1
  56. #else
  57. #ifdef LTE_NBIOT_SUPPORT
  58. #define LWIP_IPV6 1
  59. #define LWIP_IPV6_FRAG 1
  60. #else
  61. #define LWIP_IPV6 0
  62. #endif //LTE_NBIOT_SUPPORT
  63. #endif //LWIP_IPV6_ON
  64. #ifdef LWIP_IPV4_ON
  65. #define LWIP_IPV4 1
  66. #else
  67. #ifdef LTE_NBIOT_SUPPORT
  68. #define LWIP_IPV4 1
  69. #else
  70. #define LWIP_IPV4 0
  71. #endif //LTE_NBIOT_SUPPORT
  72. #endif //LWIP_IPV4_ON
  73. #ifdef CONFIG_LWIP_TCP_SACK_SUPPORT
  74. /**
  75. * LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs).
  76. */
  77. #define LWIP_TCP_SACK_OUT 1
  78. #define LWIP_TCP_MAX_SACK_NUM 4
  79. #else
  80. #define LWIP_TCP_SACK_OUT 0
  81. #endif
  82. #ifdef CONFIG_QUEC_PROJECT_FEATURE_NW
  83. #if LWIP_IPV6
  84. #define LWIP_ND6_NUM_PREFIXES 14
  85. #define LWIP_ND6_NUM_ROUTERS 14
  86. #endif
  87. #endif
  88. #ifndef CONFIG_TB_API_SUPPORT
  89. #define IP_NAT_APN_AUTO_SWITCH 1
  90. #else
  91. #define IP_NAT_APN_AUTO_SWITCH 0
  92. #endif
  93. #ifdef CONFIG_NET_NAT_SUPPORT
  94. #define IP_NAT 1
  95. #define IP_NAT_INTERNAL_FORWARD 0 //quectel open macro and update 1->0
  96. #else
  97. #define IP_NAT 0
  98. #endif
  99. #ifdef CONFIG_NET_LWIP_DEBUG
  100. #define LWIP_DEBUG 1
  101. #define ALTCP_MBEDTLS_DEBUG 1
  102. #else
  103. #define LWIP_DEBUG 0
  104. #define ALTCP_MBEDTLS_DEBUG 0
  105. #endif
  106. #define IP_REASS_MAX_PBUFS 50
  107. #if 0
  108. #define ETHARP_DEBUG 0
  109. #define NETIF_DEBUG 0
  110. #define PBUF_DEBUG 0
  111. #define API_LIB_DEBUG 0
  112. #define API_MSG_DEBUG 0
  113. #define SOCKETS_DEBUG 1
  114. #define ICMP_DEBUG 0
  115. #define IGMP_DEBUG 0
  116. #define INET_DEBUG 0
  117. #define IP_DEBUG 0
  118. #define IP_REASS_DEBUG 0
  119. #define RAW_DEBUG 0
  120. #define MEM_DEBUG 0
  121. #define MEMP_DEBUG 0
  122. #define TCP_INPUT_DEBUG 0
  123. #define TCP_FR_DEBUG 0
  124. #define TCP_RTO_DEBUG 0
  125. #define TCP_CWND_DEBUG 0
  126. #define TCP_WND_DEBUG 0
  127. #define TCP_OUTPUT_DEBUG 0
  128. #define TCP_RST_DEBUG 0
  129. #define TCP_QLEN_DEBUG 0
  130. #define UDP_DEBUG 0
  131. #define TCPIP_DEBUG 1
  132. #define SLIP_DEBUG 0
  133. #define DHCP_DEBUG 0
  134. #define AUTOIP_DEBUG 0
  135. #define IP6_DEBUG 0
  136. #define NAT_DEBUG 0
  137. #endif
  138. #ifdef CONFIG_NET_LWIP_PPP_ON
  139. #define PPP_SUPPORT 1
  140. #else
  141. #define PPP_SUPPORT 0
  142. #endif
  143. #define PPP_SERVER PPP_SUPPORT
  144. #define CCP_SUPPORT 0
  145. #define PPP_PROTOCOLNAME PPP_SUPPORT
  146. #define PRINTPKT_SUPPORT PPP_SUPPORT
  147. #define PPP_NOTIFY_PHASE PPP_SUPPORT
  148. #ifdef CONFIG_QUEC_PROJECT_FEATURE_PPP
  149. #define PAP_SUPPORT 1
  150. #define CHAP_SUPPORT 1
  151. #else
  152. #define PAP_SUPPORT 0
  153. #define CHAP_SUPPORT 0
  154. #endif
  155. #define EAP_SUPPORT 0
  156. #define MPPE_SUPPORT 0
  157. #define VJ_SUPPORT 0
  158. #ifdef CONFIG_QUEC_PROJECT_FEATURE_SSL
  159. #define LWIP_USE_EXTERNAL_MBEDTLS PPP_SUPPORT
  160. #else
  161. #define LWIP_USE_EXTERNAL_MBEDTLS 0
  162. #endif
  163. #define SLIPIF_THREAD_STACKSIZE 8192
  164. #define SLIPIF_THREAD_PRIO OSI_PRIORITY_NORMAL
  165. #define PAP_FOR_SIM_AUTH 1
  166. #ifdef CONFIG_QUEC_PROJECT_FEATURE_PPP
  167. #define PPP_AUTHGPRS_SUPPORT 1
  168. #else
  169. #define PPP_AUTHGPRS_SUPPORT 0
  170. #endif
  171. #define LWIP_TCP_KEEPALIVE 1
  172. #ifdef LTE_NBIOT_SUPPORT
  173. #define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0
  174. #endif
  175. #define LWIP_NETIF_LOOPBACK 1
  176. #define LWIP_HAVE_LOOPIF 1
  177. /** LWIP_ALTCP_TLS_MBEDTLS==1: use mbedTLS for TLS support for altcp API
  178. * mbedtls include directory must be reachable via include search path
  179. */
  180. #if defined (CONFIG_MBEDTLS_LIB_SUPPORT)
  181. #define LWIP_ALTCP_TLS_MBEDTLS 1
  182. #define LWIP_ALTCP_TLS 1
  183. #else
  184. #define LWIP_ALTCP_TLS_MBEDTLS 0
  185. #define LWIP_ALTCP_TLS 0
  186. #endif
  187. /* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */
  188. #define NO_SYS 0
  189. //#define LWIP_PROVIDE_ERRNO
  190. #define LWIP_ERRNO_STDINCLUDE
  191. #define SYS_LIGHTWEIGHT_PROT 1
  192. #define LWIP_NETCONN 0
  193. #define LWIP_SOCKET 1
  194. #define LWIP_DNS 1
  195. #define LWIP_RAW 1
  196. #if defined (CONFIG_QUEC_PROJECT_FEATURE_ETHERNET) || defined(CONFIG_QUEC_PROJECT_FEATURE_WIFI)
  197. #define LWIP_NETIF_API 1
  198. #else
  199. #define LWIP_NETIF_API 0
  200. #endif
  201. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LWIP
  202. #define LWIP_NETIF_STATUS_CALLBACK 1
  203. #endif
  204. #define LWIP_TCPIP_CORE_LOCKING 1
  205. #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
  206. #define LWIP_ARP 1
  207. #define LWIP_TIMERS 0
  208. #define LWIP_TIMEVAL_PRIVATE 0
  209. /* Enable DHCP to test it, disable UDP checksum to easier inject packets */
  210. #define LWIP_ACD 0
  211. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LWIP
  212. #define LWIP_DHCP 1 /*quectel default. netiflinkup ecm/rndis; External WIFI*/
  213. #else
  214. #define LWIP_DHCP 0
  215. #endif
  216. #define LWIP_IPV6_MLD 1
  217. #ifdef LTE_NBIOT_SUPPORT
  218. #define MEMP_MEM_MALLOC 1
  219. #else
  220. #define MEMP_MEM_MALLOC 1
  221. #endif
  222. #define MEM_LIBC_MALLOC 1
  223. #define mem_clib_free free
  224. #define mem_clib_malloc malloc
  225. #define mem_clib_calloc
  226. //#define malloc COS_MALLOC
  227. #ifdef CONFIG_SOC_8811
  228. #define DEFAULT_UDP_RECVMBOX_SIZE 32
  229. #define DEFAULT_TCP_RECVMBOX_SIZE 64
  230. #define DEFAULT_RAW_RECVMBOX_SIZE 64
  231. #else
  232. #define DEFAULT_UDP_RECVMBOX_SIZE 16
  233. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LWIP
  234. #define DEFAULT_TCP_RECVMBOX_SIZE 256
  235. #else
  236. #define DEFAULT_TCP_RECVMBOX_SIZE 600
  237. #endif
  238. #define DEFAULT_RAW_RECVMBOX_SIZE 16
  239. #endif
  240. #define LWIP_SO_RCVTIMEO 1 //quectel larson.li 2021.01.29 ali_linkSDK support
  241. #define LWIP_SO_RCVBUF 1
  242. #define LWIP_MPU_COMPATIBLE 1
  243. #define SO_REUSE 1
  244. #ifdef CONFIG_SOC_8811
  245. #define MEM_SIZE 8192*3
  246. #else
  247. #define MEM_SIZE 81920
  248. #endif
  249. #ifdef CONFIG_QUEC_PROJECT_FEATURE_LWIP
  250. #define MEMP_NUM_NETCONN 15
  251. #else
  252. #define MEMP_NUM_NETCONN 8
  253. #endif
  254. #define MEMP_NUM_UDP_PCB MEMP_NUM_NETCONN
  255. #define MEMP_NUM_TCP_PCB MEMP_NUM_NETCONN
  256. #define LWIP_SO_LINGER 1
  257. #ifdef CONFIG_NET_LWIP_TCP_ON
  258. #define LWIP_TCP 1
  259. #define TCP_MAXRTX 6
  260. /** LWIP_ALTCP==1: enable the altcp API
  261. * altcp is an abstraction layer that prevents applications linking against the
  262. * tcp.h functions but provides the same functionality. It is used to e.g. add
  263. * SSL/TLS or proxy-connect support to an application written for the tcp callback
  264. * API without that application knowing the protocol details.
  265. * Applications written against the altcp API are directly linked against the
  266. * tcp callback API for LWIP_ALTCP==0, but then cannot use layered protocols.
  267. */
  268. #define LWIP_ALTCP 1
  269. /** LWIP_ALTCP_TLS==1: enable TLS support for altcp API.
  270. * This needs a port of the functions in altcp_tls.h to a TLS library.
  271. * A port to ARM mbedtls is provided with lwIP, see apps/altcp_tls/ directory
  272. * and LWIP_ALTCP_TLS_MBEDTLS option.
  273. */
  274. #else
  275. #define LWIP_TCP 0
  276. /** LWIP_ALTCP==1: enable the altcp API
  277. * altcp is an abstraction layer that prevents applications linking against the
  278. * tcp.h functions but provides the same functionality. It is used to e.g. add
  279. * SSL/TLS or proxy-connect support to an application written for the tcp callback
  280. * API without that application knowing the protocol details.
  281. * Applications written against the altcp API are directly linked against the
  282. * tcp callback API for LWIP_ALTCP==0, but then cannot use layered protocols.
  283. */
  284. #define LWIP_ALTCP 0
  285. /** LWIP_ALTCP_TLS==1: enable TLS support for altcp API.
  286. * This needs a port of the functions in altcp_tls.h to a TLS library.
  287. * A port to ARM mbedtls is provided with lwIP, see apps/altcp_tls/ directory
  288. * and LWIP_ALTCP_TLS_MBEDTLS option.
  289. */
  290. #define LWIP_ALTCP_TLS 0
  291. #endif
  292. /* Minimal changes to opt.h required for tcp unit tests: */
  293. #define PBUF_POOL_BUFSIZE 1600
  294. #if 0
  295. #define TCP_SND_QUEUELEN 40
  296. #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
  297. #define TCP_SND_BUF (12 * TCP_MSS)
  298. #define TCP_WND (10 * TCP_MSS)
  299. #define LWIP_WND_SCALE 1
  300. #define TCP_RCV_SCALE 0
  301. #define PBUF_POOL_SIZE 40 /* pbuf tests need ~200KByte */
  302. #define MEMP_NUM_SYS_TIMEOUT 16
  303. #elif defined(CONFIG_QUEC_PROJECT_FEATURE_LWIP)
  304. #ifdef CONFIG_QUEC_PROJECT_FEATURE_TCP_WINDOWSIZE_AT
  305. #define TCP_MSS 1360
  306. extern int g_tcp_recv_window_size;
  307. extern int g_tcp_send_window_size;
  308. #define TCP_WND g_tcp_recv_window_size
  309. #define TCP_SND_BUF g_tcp_send_window_size
  310. #define TCP_WND_DEF 16 * 1024
  311. #define TCP_SND_BUF_DEF 16 * 1024
  312. #define TCP_SND_BUF_MIN 16 * 1024
  313. #define TCP_SND_BUF_MAX 100 * 1024
  314. #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
  315. #define LWIP_WND_SCALE 1
  316. #define TCP_RCV_SCALE 2
  317. #define PBUF_POOL_SIZE 250
  318. #else
  319. #define TCP_MSS 1360
  320. #define TCP_WND (97 * TCP_MSS)
  321. #define TCP_SND_BUF (8 * TCP_MSS)
  322. #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
  323. #define LWIP_WND_SCALE 1
  324. #define TCP_RCV_SCALE 2
  325. #define PBUF_POOL_SIZE 200
  326. #endif
  327. #else
  328. #define TCP_MSS 1360
  329. #define TCP_WND (42 * TCP_MSS) //quectel update from 16 to 42
  330. #define TCP_SND_BUF (8 * TCP_MSS)
  331. #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
  332. #define LWIP_WND_SCALE 1
  333. #define TCP_RCV_SCALE 0
  334. #define PBUF_POOL_SIZE 50 //quectel update from 40 to 50
  335. #endif
  336. #define LWIP_STATS 0
  337. #define LWIP_ICMP 1
  338. #define MEM_ALIGNMENT 4
  339. #define ETH_PAD_SIZE 0
  340. /* Enable IGMP and MDNS for MDNS tests */
  341. #define LWIP_IGMP 0
  342. #define LWIP_MDNS_RESPONDER 0
  343. #define LWIP_NUM_NETIF_CLIENT_DATA (LWIP_MDNS_RESPONDER)
  344. /* Minimal changes to opt.h required for etharp unit tests: */
  345. #define ETHARP_SUPPORT_STATIC_ENTRIES 0
  346. #define USE_CUSTOMER_THREAD !LWIP_TIMERS
  347. #define TCPIP_THREAD_STACKSIZE 8192
  348. #define TCPIP_THREAD_PRIO OSI_PRIORITY_NORMAL
  349. #if !LWIP_DEBUG
  350. #define tcp_debug_print_pcbs()
  351. #define sys_arch_assert(x)
  352. #define sys_arch_printf(format, ...)
  353. #define sys_arch_dump(Data, Size)
  354. #define LWIP_DBG_ALL 0
  355. #define LWIP_NOASSERT 1
  356. #else
  357. extern void tcp_debug_print_pcbs(void);
  358. #define sys_arch_assert(x) do {sys_arch_printf("Assertion \"%s\" failed at line %d in %s\n", \
  359. x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
  360. extern void sys_arch_printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
  361. extern void sys_arch_dump(const void *Data, uint16_t Size);
  362. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  363. typedef enum
  364. {
  365. QUEC_CAP_DATA_TYPE_NULL = 0,
  366. QUEC_CAP_DATA_TYPE_IP_UP = 1,
  367. QUEC_CAP_DATA_TYPE_IP_DOWN = 2,
  368. QUEC_CAP_DATA_TYPE_ETHER_UP = 3,
  369. QUEC_CAP_DATA_TYPE_ETHER_DOWN = 4
  370. } quec_cap_type_e;
  371. void sys_ether_arch_dump(quec_cap_type_e type, const void *Data, uint16_t Size);
  372. #endif
  373. #define LWIP_DBG_ALL LWIP_DBG_ON
  374. #define TCP_DEBUG_PCB_LISTS 1
  375. #endif
  376. #define TCP_DEBUG 1
  377. #define LWIP_HOOK_IP4_ROUTE_SRC(src, dest) ip4_src_route(src, dest)
  378. extern struct netif *getEtherNetIf(uint8_t nCid);
  379. extern void sys_post_ICMPevent_to_APP(uint32_t nsocketId, uint32_t nParam1, uint32_t nParam2);
  380. extern uint32_t wifi_IpaddrUpdateInd(struct netif *netif_tmp);
  381. extern uint32_t *getDNSServer(uint8_t nCid, uint8_t nSimID);
  382. #define socklen_t int
  383. #endif /* LWIP_HDR_LWIPOPTS_H */