From c1124f9f7cce552966d525707500e5b5d5b9a627 Mon Sep 17 00:00:00 2001 From: BruceHsu Date: Wed, 4 Oct 2017 22:18:21 +0800 Subject: [PATCH] Refine dhcpserver_get_leases(). Add LWIP_RAW support. --- extras/dhcpserver/dhcpserver.c | 12 ++++++------ extras/dhcpserver/include/dhcpserver.h | 2 +- lwip/include/lwipopts.h | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 lwip/include/lwipopts.h diff --git a/extras/dhcpserver/dhcpserver.c b/extras/dhcpserver/dhcpserver.c index 9df4b75..87a9c6d 100755 --- a/extras/dhcpserver/dhcpserver.c +++ b/extras/dhcpserver/dhcpserver.c @@ -118,14 +118,14 @@ int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) { } if(state->leases[i].active) { - leases[count].hwaddr=state->leases[i].hwaddr; - leases[count].ipaddr=*state->first_client_addr; + memcpy(&leases[count].hwaddr, &state->leases[i].hwaddr, sizeof(uint8_t)*6); + ip4_addr_copy(leases[count].ipaddr, state->first_client_addr); leases[count].ipaddr.addr+=count; count++; } } - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); return count; } @@ -194,7 +194,7 @@ static void dhcpserver_task(void *pxParameter) if (netbuf_len(netbuf) < offsetof(struct dhcp_msg, options)) { /* too short to be a valid DHCP client message */ netbuf_delete(netbuf); - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); continue; } if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) { @@ -208,7 +208,7 @@ static void dhcpserver_task(void *pxParameter) DHCP_OPTION_MESSAGE_TYPE_LEN, NULL); if (!message_type) { printf("DHCP Server Error: No message type field found"); - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); continue; } @@ -235,7 +235,7 @@ static void dhcpserver_task(void *pxParameter) break; } - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); } } diff --git a/extras/dhcpserver/include/dhcpserver.h b/extras/dhcpserver/include/dhcpserver.h index 4fff9e7..f6a3a25 100755 --- a/extras/dhcpserver/include/dhcpserver.h +++ b/extras/dhcpserver/include/dhcpserver.h @@ -19,7 +19,7 @@ extern "C" { #endif typedef struct { - uint8_t hwaddr[NETIF_MAX_HWADDR_LEN]; + uint8_t hwaddr[6]; ip4_addr_t ipaddr; } dhcpserver_lease_t; diff --git a/lwip/include/lwipopts.h b/lwip/include/lwipopts.h old mode 100644 new mode 100755 index 4d69eda..c86dace --- a/lwip/include/lwipopts.h +++ b/lwip/include/lwipopts.h @@ -221,6 +221,9 @@ ---------- RAW options ---------- --------------------------------- */ +#ifndef LWIP_RAW +#define LWIP_RAW 1 +#endif /* ----------------------------------