MeterLogger
dhcpserver.h
Go to the documentation of this file.
1 #ifndef __DHCPS_H__
2 #define __DHCPS_H__
3 
4 #define USE_DNS
5 
6 typedef struct dhcps_state{
9 
10 // ����dhcpclient�Զ����һ��DHCP msg�ṹ��
11 typedef struct dhcps_msg {
12  uint8_t op, htype, hlen, hops;
13  uint8_t xid[4];
14  uint16_t secs, flags;
15  uint8_t ciaddr[4];
16  uint8_t yiaddr[4];
17  uint8_t siaddr[4];
18  uint8_t giaddr[4];
19  uint8_t chaddr[16];
20  uint8_t sname[64];
21  uint8_t file[128];
22  uint8_t options[312];
23 }dhcps_msg;
24 
25 #ifndef LWIP_OPEN_SRC
26 struct dhcps_lease {
27  bool enable;
28  struct ip_addr start_ip;
29  struct ip_addr end_ip;
30 };
31 
33  OFFER_START = 0x00,
34  OFFER_ROUTER = 0x01,
35  OFFER_END
36 };
37 #endif
38 
39 struct dhcps_pool{
40  struct ip_addr ip;
41  uint8 mac[6];
43 };
44 
45 typedef struct _list_node{
46  void *pnode;
47  struct _list_node *pnext;
48 }list_node;
49 
51 #define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0
52 #define DHCPS_MAX_LEASE 0x64
53 #define BOOTP_BROADCAST 0x8000
54 
55 #define DHCP_REQUEST 1
56 #define DHCP_REPLY 2
57 #define DHCP_HTYPE_ETHERNET 1
58 #define DHCP_HLEN_ETHERNET 6
59 #define DHCP_MSG_LEN 236
60 
61 #define DHCPS_SERVER_PORT 67
62 #define DHCPS_CLIENT_PORT 68
63 
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 
72 #define DHCP_OPTION_SUBNET_MASK 1
73 #define DHCP_OPTION_ROUTER 3
74 #define DHCP_OPTION_DNS_SERVER 6
75 #define DHCP_OPTION_REQ_IPADDR 50
76 #define DHCP_OPTION_LEASE_TIME 51
77 #define DHCP_OPTION_MSG_TYPE 53
78 #define DHCP_OPTION_SERVER_ID 54
79 #define DHCP_OPTION_INTERFACE_MTU 26
80 #define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
81 #define DHCP_OPTION_BROADCAST_ADDRESS 28
82 #define DHCP_OPTION_REQ_LIST 55
83 #define DHCP_OPTION_END 255
84 
85 //#define USE_CLASS_B_NET 1
86 #define DHCPS_DEBUG 0
87 #define MAX_STATION_NUM 8
88 
89 #define DHCPS_STATE_OFFER 1
90 #define DHCPS_STATE_DECLINE 2
91 #define DHCPS_STATE_ACK 3
92 #define DHCPS_STATE_NAK 4
93 #define DHCPS_STATE_IDLE 5
94 #define DHCPS_STATE_RELEASE 6
95 
96 #define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0)
97 
98 void dhcps_start(struct ip_info *info);
99 void dhcps_stop(void);
100 
102 struct dhcps_pool *dhcps_get_mapping(uint16_t no) ICACHE_FLASH_ATTR;
103 void dhcps_set_mapping(struct ip_addr *addr, uint8 *mac, uint32 lease_time) ICACHE_FLASH_ATTR;
104 
105 #endif
106 
uint32 dhcps_lease_time
Definition: dhcpserver.c:38
uint8_t op
Definition: dhcpserver.h:12
sint16_t state
Definition: dhcpserver.h:7
void * pnode
Definition: dhcpserver.h:46
#define ICACHE_FLASH_ATTR
Definition: c_types.h:99
uint8 mac[6]
Definition: dhcpserver.h:41
uint32 lease_timer
Definition: dhcpserver.h:42
struct dhcps_msg dhcps_msg
struct _list_node list_node
void dhcps_start(struct ip_info *info)
Definition: dhcpserver.c:886
struct dhcps_pool * dhcps_get_mapping(uint16_t no) ICACHE_FLASH_ATTR
Definition: dhcpserver.c:1160
signed short sint16_t
Definition: c_types.h:34
dhcps_offer_option
unsigned char uint8
Definition: c_types.h:45
static ip_addr_t dns_ip
Definition: wifi.c:65
struct _list_node * pnext
Definition: dhcpserver.h:47
struct dhcps_state dhcps_state
void dhcps_set_mapping(struct ip_addr *addr, uint8 *mac, uint32 lease_time) ICACHE_FLASH_ATTR
Definition: dhcpserver.c:1170
unsigned int uint32
Definition: c_types.h:54
void dhcps_stop(void)
Definition: dhcpserver.c:919
uint16_t secs
Definition: dhcpserver.h:14
void dhcps_set_DNS(struct ip_addr *dns_ip) ICACHE_FLASH_ATTR
Definition: dhcpserver.c:1155