/**
 * @file lwipopts.h
 * @brief lwIP configuration for STM32F103 + CH390 in NO_SYS mode.
 */

#ifndef LWIP_LWIPOPTS_H
#define LWIP_LWIPOPTS_H

#define NO_SYS                          1
#define LWIP_SOCKET                     0
#define LWIP_NETCONN                    0
#define LWIP_NETIF_API                  0
#define SYS_LIGHTWEIGHT_PROT            1
#define LWIP_PROVIDE_ERRNO              0

#define MEM_ALIGNMENT                   4
#define MEM_SIZE                        (4 * 1024)

#define PBUF_POOL_SIZE                  8
#define PBUF_POOL_BUFSIZE               LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN)
#define MEMP_NUM_PBUF                   8
#define MEMP_NUM_RAW_PCB                2
#define MEMP_NUM_UDP_PCB                1
#define MEMP_NUM_TCP_PCB                4
#define MEMP_NUM_TCP_PCB_LISTEN         2
#define MEMP_NUM_TCP_SEG                16
#define MEMP_NUM_SYS_TIMEOUT            8
#define MEMP_NUM_NETBUF                 0
#define MEMP_NUM_NETCONN                0
#define MEMP_NUM_TCPIP_MSG_API          0
#define MEMP_NUM_TCPIP_MSG_INPKT        0

#define LWIP_IPV4                       1
#define LWIP_IPV6                       0
#define IP_FORWARD                      0
#define IP_REASSEMBLY                   0
#define IP_FRAG                         0
#define IP_OPTIONS_ALLOWED              1

#define LWIP_ICMP                       1
#define LWIP_ARP                        1
#define ARP_TABLE_SIZE                  10
#define ARP_QUEUEING                    1
#define ETHARP_SUPPORT_STATIC_ENTRIES   1

#define LWIP_DHCP                       0
#define DHCP_DOES_ARP_CHECK             1

#define LWIP_UDP                        0
#define LWIP_TCP                        1
#define LWIP_RAW                        1

#define TCP_TTL                         255
#define UDP_TTL                         255
#define ICMP_TTL                        255

#define TCP_MSS                         536
#define TCP_SND_BUF                     (4 * TCP_MSS)
#define TCP_SND_QUEUELEN                ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
#define TCP_WND                         (4 * TCP_MSS)
#define TCP_SNDLOWAT                    LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define LWIP_TCP_KEEPALIVE              1
#define TCP_QUEUE_OOSEQ                 0
#define TCP_MAXRTX                      12
#define TCP_SYNMAXRTX                   6
#define TCP_LISTEN_BACKLOG              1
#define LWIP_TCP_TIMESTAMPS             0

#define LWIP_DNS                        0
#define LWIP_IGMP                       0

#define LWIP_NETIF_STATUS_CALLBACK      0
#define LWIP_NETIF_LINK_CALLBACK        0

#define CHECKSUM_GEN_IP                 1
#define CHECKSUM_GEN_UDP                1
#define CHECKSUM_GEN_TCP                1
#define CHECKSUM_GEN_ICMP               1
#define CHECKSUM_CHECK_IP               1
#define CHECKSUM_CHECK_UDP              1
#define CHECKSUM_CHECK_TCP              1
#define CHECKSUM_CHECK_ICMP             1

#define LWIP_STATS                      0
#define LWIP_STATS_DISPLAY              0
#define LWIP_DEBUG                      0

#define LWIP_ETHERNET                   1
#define PBUF_LINK_HLEN                  14
#define PBUF_LINK_ENCAPSULATION_HLEN    0
#define LWIP_NETIF_HOSTNAME             0

#define LWIP_HAVE_LOOPIF                0
#define LWIP_NETIF_LOOPBACK             0
#define LWIP_TIMERS                     1
#define LWIP_TIMERS_CUSTOM              0

#define LWIP_RAND()                     ((uint32_t)rand())

#endif
