menu "LwIP"
config NET_USING_LWIP
    bool "Enable lwIP stack"
    select OS_USING_DEVICE
    select OS_USING_LIBC
    default n

    if NET_USING_LWIP
        choice
            prompt "lwIP version"
            default NET_USING_LWIP212 if !OS_USING_WIFI
            default NET_USING_LWIP202 if OS_USING_WIFI
            help
                Select the lwIP version

            config NET_USING_LWIP202
                bool "lwIP v2.0.2"

            config NET_USING_LWIP212
                bool "lwIP v2.1.2"
        endchoice

    if NET_USING_IPV6
        config NET_USING_LWIP_IPV6
            bool "IPV6 protocol"
            default n
    endif

    config LWIP_USING_IGMP
        bool "IGMP protocol"
        default y

    config LWIP_USING_ICMP
        bool "ICMP protocol"
        default y

    config LWIP_USING_SNMP
        bool "SNMP protocol"
        select LWIP_USING_STATS
        default n

    config LWIP_USING_DNS
        bool "Enble DNS for name resolution"
        select LWIP_USING_UDP
        default y

    config LWIP_USING_DHCP
        bool "Enable alloc ip address through DHCP"
        select LWIP_USING_UDP
        default y

        if LWIP_USING_DHCP
            config IP_SOF_BROADCAST
                int "SOF broadcast"
                default 1

            config IP_SOF_BROADCAST_RECV
                int "SOF broadcast recv"
                default 1
        endif
    
    config LWIP_USING_DHCPD
        bool "Enable DHCP server"
        default n

        if LWIP_USING_DHCPD
            config DHCPD_SERVER_IP
                string "DHCPD SERVER IP address"
                default "192.168.169.1"

            config DHCPD_USING_ROUTER
                bool "alloc gateway ip for router"
                default y

            config LWIP_USING_CUSTOMER_DNS_SERVER
                bool "Enable customer DNS server config"
                default n

            if LWIP_USING_CUSTOMER_DNS_SERVER
                config DHCP_DNS_SERVER_IP
                    string "Custom DNS server IP address"
                    default "1.1.1.1"
            endif

        endif

    menu "Static IPv4 Address"
        config LWIP_STATIC_IPADDR
            string "IPv4: IP address"
            default "192.168.1.30"

        config LWIP_STATIC_GWADDR
            string "IPv4: Gateway address"
            default "192.168.1.1"

        config LWIP_STATIC_MSKADDR
            string "IPv4: Mask address"
            default "255.255.255.0"
    endmenu

    config LWIP_USING_UDP
        bool "UDP protocol"
        default y

    config LWIP_USING_TCP
        bool "TCP protocol"
        default y

    config LWIP_USING_RAW
        bool "RAW protocol"
        default n

    config LWIP_USING_PPP
        bool "PPP protocol"
        default n

    if LWIP_USING_PPP
        config LWIP_USING_PPPOE
            bool "PPPoE protocol"
            default n

        config LWIP_USING_PPPOS
            bool "PPPoS protocol"
            default n
    endif

    config LWIP_MEMP_NUM_NETCONN
        int "the number of struct netconns"
        default 8

    config LWIP_PBUF_NUM
        int "the number of PBUF"
        default 16

    config LWIP_RAW_PCB_NUM
        int "the number of raw connection"
        default 4

    config LWIP_UDP_PCB_NUM
        int "the number of UDP socket"
        default 8 if OS_USING_VFS_NFS
        default 4

    if LWIP_USING_TCP
        config LWIP_TCP_PCB_NUM
            int "the number of TCP socket"
            default 4

        config LWIP_TCP_SEG_NUM
            int "the number of TCP segment"
            default 40

        config LWIP_TCP_SND_BUF
            int "the size of send buffer"
            default 8196

        config LWIP_TCP_WND_SIZE
            int "the size of TCP send window"
            default 8196
    endif

    config LWIP_TCP_TASK_PRIORITY
        int "the priority level value of lwIP task"
        default 10

    config LWIP_TCP_TASK_MBOX_SIZE
        int "the number of mail in the lwIP task mailbox"
        default 8

    config LWIP_TCP_TASK_STACKSIZE
        int "the stack size of lwIP task"
        default 1024

    config LWIP_NO_RX_TASK
        bool "Not use Rx task"
        default n

    config LWIP_NO_TX_TASK
        bool "Not use Tx task"
        default n

    config LWIP_ETH_TASK_PRIORITY
        int "the priority level value of ethernet task"
        default 12

    config LWIP_ETH_TASK_STACKSIZE
        int "the stack size of ethernet task"
        default 1024

    config LWIP_ETH_TASK_MBOX_SIZE
        int "the number of mail in the ethernet thread mailbox"
        default 8

    config LWIP_REASSEMBLY_FRAG
        bool "Enable IP reassembly and frag"
        default n

    config LWIP_NETIF_STATUS_CALLBACK
        int "Enable netif status callback"
        default 1
        
    config LWIP_NETIF_LINK_CALLBACK
        int "Enable netif link status callback"
        default 1

    config SO_REUSE
        int "Enable SO_REUSEADDR option"
        default 1

    config LWIP_SO_RCVTIMEO
        int "Enable receive timeout for sockets/netconns and SO_RCVTIMEO processing."
        default 1

    config LWIP_SO_SNDTIMEO
        int "Enable send timeout for sockets/netconns and SO_SNDTIMEO processing."
        default 1

    config LWIP_SO_RCVBUF
        int "Enable SO_RCVBUF processing"
        default 1

    config LWIP_ENABLE_NETIF_LOOPBACK
        bool "Enable netif loopback"
        default n

    config LWIP_NETIF_LOOPBACK
        int
        default 1 if LWIP_ENABLE_NETIF_LOOPBACK
        default 0 if !LWIP_ENABLE_NETIF_LOOPBACK

    config LWIP_USING_STATS
        bool "Enable lwIP statistics"
        default n

    config LWIP_USING_HW_CHECKSUM
        bool "Enable hardware checksum"
        default n
        
    config LWIP_USING_PING
        bool "Enable ping features"
        default n
        select LWIP_USING_ICMP
        select LWIP_USING_RAW

    if NET_USING_LWIP212
        config LWIP_USING_IPREF_TCP_SERVER
            bool "Enable ipref for tcp server"
            default n
    endif

    menuconfig LWIP_ENABLE_DEBUG
        bool "Enable lwIP Debugging Options"
        default n

    if LWIP_ENABLE_DEBUG

        config LWIP_ENABLE_SYS_DEBUG
            bool "Enable Debugging of sys.c"
            default n

        config LWIP_ENABLE_ETHARP_DEBUG
            bool "Enable Debugging of etharp.c"
            default n

        config LWIP_ENABLE_PPP_DEBUG
            bool "Enable Debugging of PPP"
            default n

        config LWIP_ENABLE_MEM_DEBUG
            bool "Enable Debugging of mem.c"
            default n

        config LWIP_ENABLE_MEMP_DEBUG
            bool "Enable Debugging of memp.c"
            default n

        config LWIP_ENABLE_PBUF_DEBUG
            bool "Enable Debugging of pbuf.c"
            default n

        config LWIP_ENABLE_API_LIB_DEBUG
            bool "Enable Debugging of api_lib.c"
            default n

        config LWIP_ENABLE_API_MSG_DEBUG
            bool "Enable Debugging of api_msg.c"
            default n

        config LWIP_ENABLE_TCPIP_DEBUG
            bool "Enable Debugging of tcpip.c"
            default n

        config LWIP_ENABLE_NETIF_DEBUG
            bool "Enable Debugging of netif.c"
            default n

        config LWIP_ENABLE_SOCKETS_DEBUG
            bool "Enable Debugging of sockets.c"
            default n

        config LWIP_ENABLE_DNS_DEBUG
            bool "Enable Debugging of DNS"
            default n

        config LWIP_ENABLE_AUTOIP_DEBUG
            bool "Enable Debugging of autoip.c"
            default n

        config LWIP_ENABLE_DHCP_DEBUG
            bool "Enable Debugging of dhcp.c"
            default n

        config LWIP_ENABLE_IP_DEBUG
            bool "Enable Debugging of IP"
            default n

        config LWIP_ENABLE_IP_REASS_DEBUG
            bool "Enable debugging in ip_frag.c for both frag & reass"
            default n

        config LWIP_ENABLE_ICMP_DEBUG
            bool "Enable Debugging of icmp.c"
            default n

        config LWIP_ENABLE_IGMP_DEBUG
            bool "Enable Debugging of igmp.c"
            default n

        config LWIP_ENABLE_UDP_DEBUG
            bool "Enable Debugging of UDP"
            default n

        config LWIP_ENABLE_TCP_DEBUG
            bool "Enable Debugging of TCP"
            default n

        config LWIP_ENABLE_TCP_INPUT_DEBUG
            bool "Enable Debugging of tcp_in.c"
            default n

        config LWIP_ENABLE_TCP_OUTPUT_DEBUG
            bool "Enable Debugging of tcp_out.c"
            default n

        config LWIP_ENABLE_TCP_RTO_DEBUG
            bool "Enable debugging in TCP for retransmit"
            default n

        config LWIP_ENABLE_TCP_CWND_DEBUG
            bool "Enable debugging for TCP congestion window"
            default n

        config LWIP_ENABLE_TCP_WND_DEBUG
            bool "Enable debugging in tcp_in.c for window updating"
            default n

        config LWIP_ENABLE_TCP_FR_DEBUG
            bool "Enable debugging in tcp_in.c for fast retransmit"
            default n

        config LWIP_ENABLE_TCP_QLEN_DEBUG
            bool "Enable debugging for TCP queue lengths"
            default n

        config LWIP_ENABLE_TCP_RST_DEBUG
            bool "Enable debugging for TCP with the RST message"
            default n

    endif

    endif
endmenu
