mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lwip: fix a mistake in parse_msg of dhcpserver.c
TW6872
This commit is contained in:
parent
af3f7d3ebe
commit
f5df40e2d1
@ -700,34 +700,39 @@ static s16_t parse_msg(struct dhcps_msg *m, u16_t len)
|
||||
first_address.addr = dhcps_poll.start_ip.addr;
|
||||
client_address.addr = client_address_plus.addr;
|
||||
renew = false;
|
||||
|
||||
if (plist != NULL){
|
||||
for (pback_node = plist; pback_node != NULL;pback_node = pback_node->pnext) {
|
||||
pdhcps_pool = pback_node->pnode;
|
||||
if (memcmp(pdhcps_pool->mac, m->chaddr, sizeof(pdhcps_pool->mac)) == 0){
|
||||
if (memcmp(&pdhcps_pool->ip.addr, m->ciaddr, sizeof(pdhcps_pool->ip.addr)) == 0) {
|
||||
renew = true;
|
||||
}
|
||||
client_address.addr = pdhcps_pool->ip.addr;
|
||||
pdhcps_pool->lease_timer = dhcps_lease_time;
|
||||
pnode = pback_node;
|
||||
goto POOL_CHECK;
|
||||
} else if (pdhcps_pool->ip.addr == client_address_plus.addr){
|
||||
addr_tmp.addr = htonl(client_address_plus.addr);
|
||||
addr_tmp.addr++;
|
||||
client_address_plus.addr = htonl(addr_tmp.addr);
|
||||
client_address.addr = client_address_plus.addr;
|
||||
}
|
||||
|
||||
for (pback_node = plist; pback_node != NULL;pback_node = pback_node->pnext) {
|
||||
pdhcps_pool = pback_node->pnode;
|
||||
if (memcmp(pdhcps_pool->mac, m->chaddr, sizeof(pdhcps_pool->mac)) == 0){
|
||||
if (memcmp(&pdhcps_pool->ip.addr, m->ciaddr, sizeof(pdhcps_pool->ip.addr)) == 0) {
|
||||
renew = true;
|
||||
}
|
||||
client_address.addr = pdhcps_pool->ip.addr;
|
||||
pdhcps_pool->lease_timer = dhcps_lease_time;
|
||||
pnode = pback_node;
|
||||
goto POOL_CHECK;
|
||||
} else if (pdhcps_pool->ip.addr == client_address_plus.addr){
|
||||
addr_tmp.addr = htonl(client_address_plus.addr);
|
||||
addr_tmp.addr++;
|
||||
client_address_plus.addr = htonl(addr_tmp.addr);
|
||||
client_address.addr = client_address_plus.addr;
|
||||
}
|
||||
|
||||
if(flag == false) { // search the fisrt unused ip
|
||||
if(first_address.addr < pdhcps_pool->ip.addr) {
|
||||
flag = true;
|
||||
} else {
|
||||
addr_tmp.addr = htonl(first_address.addr);
|
||||
addr_tmp.addr++;
|
||||
first_address.addr = htonl(addr_tmp.addr);
|
||||
}
|
||||
}
|
||||
if (flag == false) { // search the fisrt unused ip
|
||||
if (first_address.addr < pdhcps_pool->ip.addr) {
|
||||
flag = true;
|
||||
} else {
|
||||
addr_tmp.addr = htonl(first_address.addr);
|
||||
addr_tmp.addr++;
|
||||
first_address.addr = htonl(addr_tmp.addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
client_address.addr = dhcps_poll.start_ip.addr;
|
||||
}
|
||||
|
||||
if (client_address_plus.addr > dhcps_poll.end_ip.addr) {
|
||||
client_address.addr = first_address.addr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user