mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-30 12:50:58 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69e8c0a92f |
No files matched your search
@@ -9399,6 +9399,7 @@ static void rx_dhcp_client(struct mg_tcpip_if *ifp, struct pkt *pkt) {
|
|||||||
: pkt->dhcp->siaddr ? pkt->dhcp->siaddr
|
: pkt->dhcp->siaddr ? pkt->dhcp->siaddr
|
||||||
: pkt->ip->src);
|
: pkt->ip->src);
|
||||||
ifp->state = MG_TCPIP_STATE_REQ; // REQUESTING state
|
ifp->state = MG_TCPIP_STATE_REQ; // REQUESTING state
|
||||||
|
ifp->lease_expire = ifp->now + 5000; // No ACK by then: start over
|
||||||
} else if (msgtype == 5) { // DHCPACK
|
} else if (msgtype == 5) { // DHCPACK
|
||||||
if (ifp->state == MG_TCPIP_STATE_REQ && ip && gw && lease) { // got an IP
|
if (ifp->state == MG_TCPIP_STATE_REQ && ip && gw && lease) { // got an IP
|
||||||
uint64_t rand;
|
uint64_t rand;
|
||||||
@@ -10706,6 +10707,9 @@ static void mg_ip_poll(struct mg_tcpip_if *ifp, bool s1) {
|
|||||||
if (ifp->enable_dhcp_client && s1) {
|
if (ifp->enable_dhcp_client && s1) {
|
||||||
if (ifp->state == MG_TCPIP_STATE_UP) {
|
if (ifp->state == MG_TCPIP_STATE_UP) {
|
||||||
tx_dhcp_discover(ifp); // INIT (4.4.1)
|
tx_dhcp_discover(ifp); // INIT (4.4.1)
|
||||||
|
} else if (ifp->state == MG_TCPIP_STATE_REQ &&
|
||||||
|
ifp->now >= ifp->lease_expire) {
|
||||||
|
ifp->state = MG_TCPIP_STATE_UP; // REQUEST or ACK lost: DISCOVER again
|
||||||
} else if (ifp->state == MG_TCPIP_STATE_READY &&
|
} else if (ifp->state == MG_TCPIP_STATE_READY &&
|
||||||
ifp->lease_expire > 0) { // BOUND / RENEWING / REBINDING
|
ifp->lease_expire > 0) { // BOUND / RENEWING / REBINDING
|
||||||
if (ifp->now >= ifp->lease_expire) {
|
if (ifp->now >= ifp->lease_expire) {
|
||||||
|
|||||||
@@ -734,6 +734,7 @@ static void rx_dhcp_client(struct mg_tcpip_if *ifp, struct pkt *pkt) {
|
|||||||
: pkt->dhcp->siaddr ? pkt->dhcp->siaddr
|
: pkt->dhcp->siaddr ? pkt->dhcp->siaddr
|
||||||
: pkt->ip->src);
|
: pkt->ip->src);
|
||||||
ifp->state = MG_TCPIP_STATE_REQ; // REQUESTING state
|
ifp->state = MG_TCPIP_STATE_REQ; // REQUESTING state
|
||||||
|
ifp->lease_expire = ifp->now + 5000; // No ACK by then: start over
|
||||||
} else if (msgtype == 5) { // DHCPACK
|
} else if (msgtype == 5) { // DHCPACK
|
||||||
if (ifp->state == MG_TCPIP_STATE_REQ && ip && gw && lease) { // got an IP
|
if (ifp->state == MG_TCPIP_STATE_REQ && ip && gw && lease) { // got an IP
|
||||||
uint64_t rand;
|
uint64_t rand;
|
||||||
@@ -2041,6 +2042,9 @@ static void mg_ip_poll(struct mg_tcpip_if *ifp, bool s1) {
|
|||||||
if (ifp->enable_dhcp_client && s1) {
|
if (ifp->enable_dhcp_client && s1) {
|
||||||
if (ifp->state == MG_TCPIP_STATE_UP) {
|
if (ifp->state == MG_TCPIP_STATE_UP) {
|
||||||
tx_dhcp_discover(ifp); // INIT (4.4.1)
|
tx_dhcp_discover(ifp); // INIT (4.4.1)
|
||||||
|
} else if (ifp->state == MG_TCPIP_STATE_REQ &&
|
||||||
|
ifp->now >= ifp->lease_expire) {
|
||||||
|
ifp->state = MG_TCPIP_STATE_UP; // REQUEST or ACK lost: DISCOVER again
|
||||||
} else if (ifp->state == MG_TCPIP_STATE_READY &&
|
} else if (ifp->state == MG_TCPIP_STATE_READY &&
|
||||||
ifp->lease_expire > 0) { // BOUND / RENEWING / REBINDING
|
ifp->lease_expire > 0) { // BOUND / RENEWING / REBINDING
|
||||||
if (ifp->now >= ifp->lease_expire) {
|
if (ifp->now >= ifp->lease_expire) {
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ static void test_statechange(void) {
|
|||||||
onstatechange(&iface);
|
onstatechange(&iface);
|
||||||
ASSERT(executed == true);
|
ASSERT(executed == true);
|
||||||
executed = false;
|
executed = false;
|
||||||
|
iface.enable_dhcp_client = true; // DHCP REQUEST unanswered: start over
|
||||||
|
iface.state = MG_TCPIP_STATE_REQ, iface.lease_expire = 0;
|
||||||
|
mg_ip_poll(&iface, true);
|
||||||
|
ASSERT(iface.state == MG_TCPIP_STATE_UP);
|
||||||
}
|
}
|
||||||
#if MG_ENABLE_IPV6
|
#if MG_ENABLE_IPV6
|
||||||
static void mif6_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
static void mif6_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||||
|
|||||||
Reference in new issue
Block a user