dhcpserver.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef __DHCPS_H__
  2. #define __DHCPS_H__
  3. #include "lwipopts.h"
  4. #define USE_DNS
  5. typedef struct dhcps_state{
  6. sint16_t state;
  7. } dhcps_state;
  8. // ����dhcpclient�Զ����һ��DHCP msg�ṹ��
  9. typedef struct dhcps_msg {
  10. uint8_t op, htype, hlen, hops;
  11. uint8_t xid[4];
  12. uint16_t secs, flags;
  13. uint8_t ciaddr[4];
  14. uint8_t yiaddr[4];
  15. uint8_t siaddr[4];
  16. uint8_t giaddr[4];
  17. uint8_t chaddr[16];
  18. uint8_t sname[64];
  19. uint8_t file[128];
  20. uint8_t options[312];
  21. }dhcps_msg;
  22. #ifndef LWIP_OPEN_SRC
  23. struct dhcps_lease {
  24. bool enable;
  25. struct ip_addr start_ip;
  26. struct ip_addr end_ip;
  27. };
  28. enum dhcps_offer_option{
  29. OFFER_START = 0x00,
  30. OFFER_ROUTER = 0x01,
  31. OFFER_END
  32. };
  33. #endif
  34. typedef enum {
  35. DHCPS_TYPE_DYNAMIC,
  36. DHCPS_TYPE_STATIC
  37. } dhcps_type_t;
  38. typedef enum {
  39. DHCPS_STATE_ONLINE,
  40. DHCPS_STATE_OFFLINE
  41. } dhcps_state_t;
  42. struct dhcps_pool{
  43. struct ip_addr ip;
  44. uint8 mac[6];
  45. uint32 lease_timer;
  46. dhcps_type_t type;
  47. dhcps_state_t state;
  48. };
  49. typedef struct _list_node{
  50. void *pnode;
  51. struct _list_node *pnext;
  52. }list_node;
  53. extern uint32 dhcps_lease_time;
  54. #define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0
  55. #define DHCPS_MAX_LEASE 0x64
  56. #define BOOTP_BROADCAST 0x8000
  57. #define DHCP_REQUEST 1
  58. #define DHCP_REPLY 2
  59. #define DHCP_HTYPE_ETHERNET 1
  60. #define DHCP_HLEN_ETHERNET 6
  61. #define DHCP_MSG_LEN 236
  62. #define DHCPS_SERVER_PORT 67
  63. #define DHCPS_CLIENT_PORT 68
  64. #define DHCPDISCOVER 1
  65. #define DHCPOFFER 2
  66. #define DHCPREQUEST 3
  67. #define DHCPDECLINE 4
  68. #define DHCPACK 5
  69. #define DHCPNAK 6
  70. #define DHCPRELEASE 7
  71. #define DHCP_OPTION_SUBNET_MASK 1
  72. #define DHCP_OPTION_ROUTER 3
  73. #define DHCP_OPTION_DNS_SERVER 6
  74. #define DHCP_OPTION_REQ_IPADDR 50
  75. #define DHCP_OPTION_LEASE_TIME 51
  76. #define DHCP_OPTION_MSG_TYPE 53
  77. #define DHCP_OPTION_SERVER_ID 54
  78. #define DHCP_OPTION_INTERFACE_MTU 26
  79. #define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
  80. #define DHCP_OPTION_BROADCAST_ADDRESS 28
  81. #define DHCP_OPTION_REQ_LIST 55
  82. #define DHCP_OPTION_END 255
  83. //#define USE_CLASS_B_NET 1
  84. #define DHCPS_DEBUG 0
  85. #define MAX_STATION_NUM 8
  86. #define DHCPS_STATE_OFFER 1
  87. #define DHCPS_STATE_DECLINE 2
  88. #define DHCPS_STATE_ACK 3
  89. #define DHCPS_STATE_NAK 4
  90. #define DHCPS_STATE_IDLE 5
  91. #define DHCPS_STATE_RELEASE 6
  92. #define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0)
  93. void dhcps_start(struct ip_info *info);
  94. void dhcps_stop(void);
  95. #endif