#ifndef __LWIP_INIT_H
#define __LWIP_INIT_H

#include "lwip/netif.h"
#include "lwip/opt.h"
#include "lwip/tcpip.h"
#include "netif/etharp.h"
#include <stdint.h>
#include <stdio.h>
#ifdef USE_DHCP
#include "lwip/dhcp.h"
#include "lwip/prot/dhcp.h"
#endif

#define LWIP_MAX_DHCP_TRIES 4 // DHCP服务器最大重试次数

// #define DHCP_OFF              (uint8_t)0
// #define DHCP_START            (uint8_t)1
// #define DHCP_WAIT_ADDRESS     (uint8_t)2
// #define DHCP_ADDRESS_ASSIGNED (uint8_t)3
// #define DHCP_TIMEOUT          (uint8_t)4
// #define DHCP_LINK_DOWN        (uint8_t)5
// #define DHCP_LINK_FAIL        (uint8_t)0xff

typedef enum
{
    DHCP_START = 0,
    DHCP_WAIT_ADDRESS,
    DHCP_ADDRESS_ASSIGNED,
    DHCP_TIMEOUT,
    DHCP_LINK_DOWN,
    DHCP_LINK_FAIL
} dhcp_state_enum;

typedef struct
{
    uint8_t mac[6];      // MAC地址
    uint8_t remoteip[4]; //远端主机IP地址
    uint8_t ip[4];       //本机IP地址
    uint8_t netmask[4];  //子网掩码
    uint8_t gateway[4];  //默认网关的IP地址
    uint8_t dhcpstatus;  // dhcp状态
} __lwip_dev;

extern __lwip_dev ethdev;  // lwip控制结构体
extern __lwip_dev dm9kdev; // lwip控制结构体

void lwip_setup(void);

#endif /* __LWIP_INIT_H */
