lwip_init.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef __LWIP_INIT_H
  2. #define __LWIP_INIT_H
  3. #include "lwip/netif.h"
  4. #include "lwip/opt.h"
  5. #include "lwip/tcpip.h"
  6. #include "netif/etharp.h"
  7. #include <stdint.h>
  8. #include <stdio.h>
  9. #ifdef USE_DHCP
  10. #include "lwip/dhcp.h"
  11. #include "lwip/prot/dhcp.h"
  12. #endif
  13. #define LWIP_MAX_DHCP_TRIES 4 // DHCP服务器最大重试次数
  14. // #define DHCP_OFF (uint8_t)0
  15. // #define DHCP_START (uint8_t)1
  16. // #define DHCP_WAIT_ADDRESS (uint8_t)2
  17. // #define DHCP_ADDRESS_ASSIGNED (uint8_t)3
  18. // #define DHCP_TIMEOUT (uint8_t)4
  19. // #define DHCP_LINK_DOWN (uint8_t)5
  20. // #define DHCP_LINK_FAIL (uint8_t)0xff
  21. typedef enum
  22. {
  23. DHCP_START = 0,
  24. DHCP_WAIT_ADDRESS,
  25. DHCP_ADDRESS_ASSIGNED,
  26. DHCP_TIMEOUT,
  27. DHCP_LINK_DOWN,
  28. DHCP_LINK_FAIL
  29. } dhcp_state_enum;
  30. typedef struct
  31. {
  32. uint8_t mac[6]; // MAC地址
  33. uint8_t remoteip[4]; //远端主机IP地址
  34. uint8_t ip[4]; //本机IP地址
  35. uint8_t netmask[4]; //子网掩码
  36. uint8_t gateway[4]; //默认网关的IP地址
  37. uint8_t dhcpstatus; // dhcp状态
  38. } __lwip_dev;
  39. extern __lwip_dev ethdev; // lwip控制结构体
  40. extern __lwip_dev dm9kdev; // lwip控制结构体
  41. void lwip_setup(void);
  42. #endif /* __LWIP_INIT_H */