Refine dhcpserver_get_leases().

Add LWIP_RAW support.
This commit is contained in:
BruceHsu 2017-10-04 22:18:21 +08:00
parent cbdacf5ca1
commit c1124f9f7c
3 changed files with 10 additions and 7 deletions

View file

@ -118,14 +118,14 @@ int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) {
} }
if(state->leases[i].active) { if(state->leases[i].active) {
leases[count].hwaddr=state->leases[i].hwaddr; memcpy(&leases[count].hwaddr, &state->leases[i].hwaddr, sizeof(uint8_t)*6);
leases[count].ipaddr=*state->first_client_addr; ip4_addr_copy(leases[count].ipaddr, state->first_client_addr);
leases[count].ipaddr.addr+=count; leases[count].ipaddr.addr+=count;
count++; count++;
} }
} }
taskLEAVE_CRITICAL(); taskEXIT_CRITICAL();
return count; return count;
} }
@ -194,7 +194,7 @@ static void dhcpserver_task(void *pxParameter)
if (netbuf_len(netbuf) < offsetof(struct dhcp_msg, options)) { if (netbuf_len(netbuf) < offsetof(struct dhcp_msg, options)) {
/* too short to be a valid DHCP client message */ /* too short to be a valid DHCP client message */
netbuf_delete(netbuf); netbuf_delete(netbuf);
taskLEAVE_CRITICAL(); taskEXIT_CRITICAL();
continue; continue;
} }
if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) { if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) {
@ -208,7 +208,7 @@ static void dhcpserver_task(void *pxParameter)
DHCP_OPTION_MESSAGE_TYPE_LEN, NULL); DHCP_OPTION_MESSAGE_TYPE_LEN, NULL);
if (!message_type) { if (!message_type) {
printf("DHCP Server Error: No message type field found"); printf("DHCP Server Error: No message type field found");
taskLEAVE_CRITICAL(); taskEXIT_CRITICAL();
continue; continue;
} }
@ -235,7 +235,7 @@ static void dhcpserver_task(void *pxParameter)
break; break;
} }
taskLEAVE_CRITICAL(); taskEXIT_CRITICAL();
} }
} }

View file

@ -19,7 +19,7 @@ extern "C" {
#endif #endif
typedef struct { typedef struct {
uint8_t hwaddr[NETIF_MAX_HWADDR_LEN]; uint8_t hwaddr[6];
ip4_addr_t ipaddr; ip4_addr_t ipaddr;
} dhcpserver_lease_t; } dhcpserver_lease_t;

3
lwip/include/lwipopts.h Normal file → Executable file
View file

@ -221,6 +221,9 @@
---------- RAW options ---------- ---------- RAW options ----------
--------------------------------- ---------------------------------
*/ */
#ifndef LWIP_RAW
#define LWIP_RAW 1
#endif
/* /*
---------------------------------- ----------------------------------