/**
 * @file lwipopts.h
 * @brief lwIP Configuration for NexusOS Membrane
 */

#ifndef LWIP_LWIPOPTS_H
#define LWIP_LWIPOPTS_H

// --- LwIP Debug Constants (Needed before opt.h defines them) ---
#define LWIP_DBG_ON            0x80U
#define LWIP_DBG_OFF           0x00U
#define LWIP_DBG_TRACE         0x40U
#define LWIP_DBG_STATE         0x20U
#define LWIP_DBG_FRESH         0x10U
#define LWIP_DBG_HALT          0x08U

#define NO_SYS                  1
#define LWIP_SOCKET             0
#define LWIP_NETCONN            0

// DHCP Support
#define LWIP_DHCP               1
#define LWIP_ACD                0
#define LWIP_DHCP_DOES_ACD_CHECK 0
#define LWIP_AUTOIP             0
#define LWIP_UDP                1
#define LWIP_NETIF_HOSTNAME     1
#define LWIP_RAW                1

// Performance & Memory
#define MEM_ALIGNMENT           8
#define MEM_SIZE                (64 * 1024)
#define MEMP_NUM_PBUF           16
#define MEMP_NUM_UDP_PCB        4
#define MEMP_NUM_TCP_PCB        4
#define PBUF_POOL_SIZE          32

// Network Interface
#define LWIP_ETHERNET           1
#define LWIP_ARP                1
#define ETHARP_SUPPORT_VLAN     0

// Checksum Configuration
// CHECK disabled (don't validate incoming - helps debug)
// GEN enabled (QEMU user-mode networking requires valid checksums)
#define CHECKSUM_CHECK_UDP      0
#define CHECKSUM_CHECK_TCP      0
#define CHECKSUM_CHECK_IP       0
#define CHECKSUM_CHECK_ICMP     0
#define CHECKSUM_GEN_UDP        1
#define CHECKSUM_GEN_TCP        1
#define CHECKSUM_GEN_IP         1
#define CHECKSUM_GEN_ICMP       1

// Loopback Support
#define LWIP_HAVE_LOOPIF        1
#define LWIP_NETIF_LOOPBACK     1
#define LWIP_LOOPBACK_MAX_PBUFS 8

// Debugging (Loud Mode)
#define LWIP_DEBUG              1
#define LWIP_PLATFORM_DIAG(x)   lwip_platform_diag x

#define DHCP_DEBUG              (LWIP_DBG_ON | LWIP_DBG_TRACE | LWIP_DBG_STATE)
#define UDP_DEBUG               (LWIP_DBG_ON | LWIP_DBG_TRACE)
#define NETIF_DEBUG             (LWIP_DBG_ON | LWIP_DBG_TRACE | LWIP_DBG_STATE)
#define IP_DEBUG                (LWIP_DBG_ON | LWIP_DBG_TRACE)
#define ICMP_DEBUG              (LWIP_DBG_ON | LWIP_DBG_TRACE)
//#define MEM_DEBUG               (LWIP_DBG_ON | LWIP_DBG_TRACE)
//#define MEMP_DEBUG              (LWIP_DBG_ON | LWIP_DBG_TRACE)
//#define PBUF_DEBUG              (LWIP_DBG_ON | LWIP_DBG_TRACE)
#define ETHERNET_DEBUG          (LWIP_DBG_ON | LWIP_DBG_TRACE)
#define ETHARP_DEBUG            (LWIP_DBG_ON | LWIP_DBG_TRACE)

#define LWIP_DBG_MIN_LEVEL      0
#define LWIP_DBG_TYPES_ON       0xFFU

// Endianness
#undef BYTE_ORDER
#define BYTE_ORDER 1234

#endif
