Merge 2e4ec5c96e into 546cc47121
This commit is contained in:
commit
6f6b2cc973
10 changed files with 58 additions and 3 deletions
14
.gitmodules
vendored
14
.gitmodules
vendored
|
|
@ -1,6 +1,6 @@
|
|||
[submodule "lwip/lwip"]
|
||||
path = lwip/lwip
|
||||
url = https://github.com/ourairquality/lwip.git
|
||||
url = https://github.com/ccbruce0812/lwip.git
|
||||
[submodule "extras/mbedtls/mbedtls"]
|
||||
path = extras/mbedtls/mbedtls
|
||||
url = https://github.com/ARMmbed/mbedtls.git
|
||||
|
|
@ -28,3 +28,15 @@
|
|||
[submodule "extras/crc_generic/crc_lib"]
|
||||
path = extras/crc_generic/crc_lib
|
||||
url = https://github.com/Zaltora/crc_generic_lib.git
|
||||
[submodule "extras/kt0803l"]
|
||||
path = extras/kt0803l
|
||||
url = https://github.com/ccbruce0812/kt0803l.git
|
||||
[submodule "extras/rda5807m"]
|
||||
path = extras/rda5807m
|
||||
url = https://github.com/ccbruce0812/rda5807m.git
|
||||
[submodule "examples/rda5807m_test"]
|
||||
path = examples/rda5807m_test
|
||||
url = https://github.com/ccbruce0812/rda5807m_test.git
|
||||
[submodule "extras/mcpwm"]
|
||||
path = extras/mcpwm
|
||||
url = https://github.com/ccbruce0812/mcpwm.git
|
||||
|
|
|
|||
1
examples/rda5807m_test
Submodule
1
examples/rda5807m_test
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 439b9fa3dfd8ea29cfef60184889ea461f56a7d7
|
||||
29
extras/dhcpserver/dhcpserver.c
Normal file → Executable file
29
extras/dhcpserver/dhcpserver.c
Normal file → Executable file
|
|
@ -106,6 +106,29 @@ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases)
|
|||
xTaskCreate(dhcpserver_task, "DHCP Server", 448, NULL, 2, &dhcpserver_task_handle);
|
||||
}
|
||||
|
||||
uint32_t dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) {
|
||||
uint32_t i=0, count=0;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
for(i=0;i<state->max_leases;i++) {
|
||||
if(count>=capacity) {
|
||||
count=capacity;
|
||||
break;
|
||||
}
|
||||
|
||||
if(state->leases[i].active) {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
taskEXIT_CRITICAL();
|
||||
return count;
|
||||
}
|
||||
|
||||
void dhcpserver_stop(void)
|
||||
{
|
||||
if (dhcpserver_task_handle) {
|
||||
|
|
@ -150,6 +173,8 @@ static void dhcpserver_task(void *pxParameter)
|
|||
printf("DHCP Server Error: Failed to receive DHCP packet. err=%d\r\n", err);
|
||||
continue;
|
||||
}
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
|
||||
/* expire any leases that have passed */
|
||||
uint32_t now = xTaskGetTickCount();
|
||||
|
|
@ -169,6 +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);
|
||||
taskEXIT_CRITICAL();
|
||||
continue;
|
||||
}
|
||||
if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) {
|
||||
|
|
@ -182,6 +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");
|
||||
taskEXIT_CRITICAL();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +234,8 @@ static void dhcpserver_task(void *pxParameter)
|
|||
printf("DHCP Server Error: Unsupported message type %d\r\n", *message_type);
|
||||
break;
|
||||
}
|
||||
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
7
extras/dhcpserver/include/dhcpserver.h
Normal file → Executable file
7
extras/dhcpserver/include/dhcpserver.h
Normal file → Executable file
|
|
@ -18,6 +18,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t hwaddr[6];
|
||||
ip4_addr_t ipaddr;
|
||||
} dhcpserver_lease_t;
|
||||
|
||||
/* Start DHCP server.
|
||||
|
||||
Static IP of server should already be set and network interface enabled.
|
||||
|
|
@ -28,7 +33,7 @@ extern "C" {
|
|||
*/
|
||||
void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases);
|
||||
|
||||
void dhcpserver_get_lease(const ip4_addr_t *first_client_addr, uint8_t max_leases);
|
||||
uint32_t dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity);
|
||||
|
||||
/* Stop DHCP server.
|
||||
*/
|
||||
|
|
|
|||
1
extras/kt0803l
Submodule
1
extras/kt0803l
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 32f7a131390d2f73f5260fa383383f1fae0e96db
|
||||
1
extras/mcpwm
Submodule
1
extras/mcpwm
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0f76d8141318899388c990c45c347ae5f37b9c07
|
||||
1
extras/rda5807m
Submodule
1
extras/rda5807m
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit fc137d42d5189a8d830f027fcd3c65c3048aa9ab
|
||||
|
|
@ -101,6 +101,8 @@ typedef int sys_prot_t;
|
|||
#define LWIP_PLATFORM_HTONS(_n) ((u16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff)))
|
||||
#define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) ))
|
||||
|
||||
#ifndef LWIP_RAND
|
||||
#define LWIP_RAND() hwrand()
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
|
|
|
|||
3
lwip/include/lwipopts.h
Normal file → Executable file
3
lwip/include/lwipopts.h
Normal file → Executable file
|
|
@ -221,6 +221,9 @@
|
|||
---------- RAW options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
#ifndef LWIP_RAW
|
||||
#define LWIP_RAW 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 74676d46f0bc5ed82515f8e247008b7c45ec6cf6
|
||||
Subproject commit e5bf00eab33ad371994368dbe53f7b2d456ec884
|
||||
Loading…
Add table
Add a link
Reference in a new issue