From 2ece3a8b4cd80b288e0fec9e41bd30ec58ea2593 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 9 Mar 2023 11:25:02 -0300 Subject: [PATCH] MIP_STATE_* -> MG_TCPIP_STATE_* --- examples/rp2040/pico-w5500/main.c | 2 +- examples/stm32/nucleo-f429zi-baremetal/main.c | 2 +- examples/stm32/nucleo-f429zi-freertos/main.c | 2 +- examples/stm32/nucleo-f746zg-baremetal/main.c | 2 +- examples/stm32/nucleo-f746zg-freertos/main.c | 2 +- examples/stm32/nucleo-h743zi-baremetal/main.c | 2 +- examples/ti/ek-tm4c1294xl-baremetal/main.c | 2 +- examples/ti/ek-tm4c1294xl-freertos/main.c | 2 +- mongoose.c | 26 ++++++------ mongoose.h | 40 +++++++++---------- src/tcpip/driver_stm32.c | 2 +- src/tcpip/driver_stm32h.c | 2 +- src/tcpip/driver_tm4c.c | 2 +- src/tcpip/tcpip.c | 20 +++++----- src/tcpip/tcpip.h | 40 +++++++++---------- test/mip_test.c | 2 +- 16 files changed, 75 insertions(+), 75 deletions(-) diff --git a/examples/rp2040/pico-w5500/main.c b/examples/rp2040/pico-w5500/main.c index 2e33b2a7..e605c3e4 100644 --- a/examples/rp2040/pico-w5500/main.c +++ b/examples/rp2040/pico-w5500/main.c @@ -83,7 +83,7 @@ int main(void) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/stm32/nucleo-f429zi-baremetal/main.c b/examples/stm32/nucleo-f429zi-baremetal/main.c index 91eb5477..755a537c 100644 --- a/examples/stm32/nucleo-f429zi-baremetal/main.c +++ b/examples/stm32/nucleo-f429zi-baremetal/main.c @@ -73,7 +73,7 @@ int main(void) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/stm32/nucleo-f429zi-freertos/main.c b/examples/stm32/nucleo-f429zi-freertos/main.c index 3e156311..87fe7c7d 100644 --- a/examples/stm32/nucleo-f429zi-freertos/main.c +++ b/examples/stm32/nucleo-f429zi-freertos/main.c @@ -60,7 +60,7 @@ static void server(void *args) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/stm32/nucleo-f746zg-baremetal/main.c b/examples/stm32/nucleo-f746zg-baremetal/main.c index 91eb5477..755a537c 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/main.c +++ b/examples/stm32/nucleo-f746zg-baremetal/main.c @@ -73,7 +73,7 @@ int main(void) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/stm32/nucleo-f746zg-freertos/main.c b/examples/stm32/nucleo-f746zg-freertos/main.c index 3e156311..87fe7c7d 100644 --- a/examples/stm32/nucleo-f746zg-freertos/main.c +++ b/examples/stm32/nucleo-f746zg-freertos/main.c @@ -60,7 +60,7 @@ static void server(void *args) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/stm32/nucleo-h743zi-baremetal/main.c b/examples/stm32/nucleo-h743zi-baremetal/main.c index 893f2f71..3ca94030 100644 --- a/examples/stm32/nucleo-h743zi-baremetal/main.c +++ b/examples/stm32/nucleo-h743zi-baremetal/main.c @@ -75,7 +75,7 @@ int main(void) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/ti/ek-tm4c1294xl-baremetal/main.c b/examples/ti/ek-tm4c1294xl-baremetal/main.c index f5221b8b..388fe8ce 100644 --- a/examples/ti/ek-tm4c1294xl-baremetal/main.c +++ b/examples/ti/ek-tm4c1294xl-baremetal/main.c @@ -84,7 +84,7 @@ int main(void) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/examples/ti/ek-tm4c1294xl-freertos/main.c b/examples/ti/ek-tm4c1294xl-freertos/main.c index 74279af8..9b8db8fb 100644 --- a/examples/ti/ek-tm4c1294xl-freertos/main.c +++ b/examples/ti/ek-tm4c1294xl-freertos/main.c @@ -69,7 +69,7 @@ static void server(void *args) { mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); - while (mif.state != MIP_STATE_READY) { + while (mif.state != MG_TCPIP_STATE_READY) { mg_mgr_poll(&mgr, 0); } diff --git a/mongoose.c b/mongoose.c index e946730f..7947bc37 100644 --- a/mongoose.c +++ b/mongoose.c @@ -6511,7 +6511,7 @@ static size_t mg_tcpip_driver_stm32_tx(const void *buf, size_t len, static bool mg_tcpip_driver_stm32_up(struct mg_tcpip_if *ifp) { uint32_t bsr = eth_read_phy(PHY_ADDR, PHY_BSR); bool up = bsr & BIT(2) ? 1 : 0; - if ((ifp->state == MIP_STATE_DOWN) && up) { // link state just went up + if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up uint32_t scsr = eth_read_phy(PHY_ADDR, PHY_CSCR); uint32_t maccr = ETH->MACCR | BIT(14) | BIT(11); // 100M, Full-duplex if ((scsr & BIT(3)) == 0) maccr &= ~BIT(14); // 10M @@ -6787,7 +6787,7 @@ static size_t mg_tcpip_driver_stm32h_tx(const void *buf, size_t len, static bool mg_tcpip_driver_stm32h_up(struct mg_tcpip_if *ifp) { uint32_t bsr = eth_read_phy(PHY_ADDR, PHY_BSR); bool up = bsr & BIT(2) ? 1 : 0; - if ((ifp->state == MIP_STATE_DOWN) && up) { // link state just went up + if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up uint32_t scsr = eth_read_phy(PHY_ADDR, PHY_CSCR); uint32_t maccr = ETH->MACCR | BIT(14) | BIT(13); // 100M, Full-duplex if ((scsr & BIT(3)) == 0) maccr &= ~BIT(14); // 10M @@ -7042,7 +7042,7 @@ static size_t mg_tcpip_driver_tm4c_tx(const void *buf, size_t len, static bool mg_tcpip_driver_tm4c_up(struct mg_tcpip_if *ifp) { uint32_t bmsr = emac_read_phy(EPHY_ADDR, EPHYBMSR); bool up = (bmsr & BIT(2)) ? 1 : 0; - if ((ifp->state == MIP_STATE_DOWN) && up) { // link state just went up + if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up uint32_t sts = emac_read_phy(EPHY_ADDR, EPHYSTS); uint32_t emaccfg = EMAC->EMACCFG | BIT(14) | BIT(11); // 100M, Full-duplex if (sts & BIT(1)) emaccfg &= ~BIT(14); // 10M @@ -7352,7 +7352,7 @@ static void arp_ask(struct mg_tcpip_if *ifp, uint32_t ip) { } static void onstatechange(struct mg_tcpip_if *ifp) { - if (ifp->state == MIP_STATE_READY) { + if (ifp->state == MG_TCPIP_STATE_READY) { MG_INFO(("READY, IP: %M", mg_print_ip4, &ifp->ip)); MG_INFO((" GW: %M", mg_print_ip4, &ifp->gw)); if (ifp->lease_expire > ifp->now) { @@ -7360,10 +7360,10 @@ static void onstatechange(struct mg_tcpip_if *ifp) { (" Lease: %lld sec", (ifp->lease_expire - ifp->now) / 1000)); } arp_ask(ifp, ifp->gw); - } else if (ifp->state == MIP_STATE_UP) { + } else if (ifp->state == MG_TCPIP_STATE_UP) { MG_ERROR(("Link up")); srand((unsigned int) mg_millis()); - } else if (ifp->state == MIP_STATE_DOWN) { + } else if (ifp->state == MG_TCPIP_STATE_DOWN) { MG_ERROR(("Link down")); } } @@ -7533,7 +7533,7 @@ static void rx_dhcp_client(struct mg_tcpip_if *ifp, struct pkt *pkt) { if (ip && mask && gw && ifp->ip == 0) { memcpy(ifp->gwmac, pkt->eth->src, sizeof(ifp->gwmac)); ifp->ip = ip, ifp->gw = gw, ifp->mask = mask; - ifp->state = MIP_STATE_READY; + ifp->state = MG_TCPIP_STATE_READY; onstatechange(ifp); tx_dhcp_request(ifp, pkt->eth->src, ip, pkt->dhcp->siaddr); uint64_t rand; @@ -7916,16 +7916,16 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t uptime_ms) { // Handle physical interface up/down status if (expired_1000ms && ifp->driver->up) { bool up = ifp->driver->up(ifp); - bool current = ifp->state != MIP_STATE_DOWN; + bool current = ifp->state != MG_TCPIP_STATE_DOWN; if (up != current) { - ifp->state = up == false ? MIP_STATE_DOWN - : ifp->enable_dhcp_client ? MIP_STATE_UP - : MIP_STATE_READY; + ifp->state = up == false ? MG_TCPIP_STATE_DOWN + : ifp->enable_dhcp_client ? MG_TCPIP_STATE_UP + : MG_TCPIP_STATE_READY; if (!up && ifp->enable_dhcp_client) ifp->ip = 0; onstatechange(ifp); } } - if (ifp->state == MIP_STATE_DOWN) return; + if (ifp->state == MG_TCPIP_STATE_DOWN) return; // If IP not configured, send DHCP if (ifp->ip == 0 && expired_1000ms) tx_dhcp_discover(ifp); @@ -8109,7 +8109,7 @@ void mg_mgr_poll(struct mg_mgr *mgr, int ms) { bool mg_send(struct mg_connection *c, const void *buf, size_t len) { struct mg_tcpip_if *ifp = (struct mg_tcpip_if *) c->mgr->priv; bool res = false; - if (ifp->ip == 0 || ifp->state != MIP_STATE_READY) { + if (ifp->ip == 0 || ifp->state != MG_TCPIP_STATE_READY) { mg_error(c, "net down"); } else if (c->is_udp) { struct connstate *s = (struct connstate *) (c + 1); diff --git a/mongoose.h b/mongoose.h index 69496b80..5f2ca175 100644 --- a/mongoose.h +++ b/mongoose.h @@ -1514,32 +1514,32 @@ struct mg_tcpip_driver { // Network interface struct mg_tcpip_if { - uint8_t mac[6]; // MAC address. Must be set to a valid MAC - uint32_t ip, mask, gw; // IP address, mask, default gateway - struct mg_str tx; // Output (TX) buffer - bool enable_dhcp_client; // Enable DCHP client - bool enable_dhcp_server; // Enable DCHP server - bool enable_crc32_check; // Do a CRC check on rx frames and strip it - bool enable_mac_check; // Do a MAC check on rx frames + uint8_t mac[6]; // MAC address. Must be set to a valid MAC + uint32_t ip, mask, gw; // IP address, mask, default gateway + struct mg_str tx; // Output (TX) buffer + bool enable_dhcp_client; // Enable DCHP client + bool enable_dhcp_server; // Enable DCHP server + bool enable_crc32_check; // Do a CRC check on rx frames and strip it + bool enable_mac_check; // Do a MAC check on rx frames struct mg_tcpip_driver *driver; // Low level driver void *driver_data; // Driver-specific data struct mg_mgr *mgr; // Mongoose event manager struct mg_queue recv_queue; // Receive queue // Internal state, user can use it but should not change it - uint8_t gwmac[6]; // Router's MAC - uint64_t now; // Current time - uint64_t timer_1000ms; // 1000 ms timer: for DHCP and link state - uint64_t lease_expire; // Lease expiration time - uint16_t eport; // Next ephemeral port - volatile uint32_t ndrop; // Number of received, but dropped frames - volatile uint32_t nrecv; // Number of received frames - volatile uint32_t nsent; // Number of transmitted frames - volatile uint32_t nerr; // Number of driver errors - uint8_t state; // Current state -#define MIP_STATE_DOWN 0 // Interface is down -#define MIP_STATE_UP 1 // Interface is up -#define MIP_STATE_READY 2 // Interface is up and has IP + uint8_t gwmac[6]; // Router's MAC + uint64_t now; // Current time + uint64_t timer_1000ms; // 1000 ms timer: for DHCP and link state + uint64_t lease_expire; // Lease expiration time + uint16_t eport; // Next ephemeral port + volatile uint32_t ndrop; // Number of received, but dropped frames + volatile uint32_t nrecv; // Number of received frames + volatile uint32_t nsent; // Number of transmitted frames + volatile uint32_t nerr; // Number of driver errors + uint8_t state; // Current state +#define MG_TCPIP_STATE_DOWN 0 // Interface is down +#define MG_TCPIP_STATE_UP 1 // Interface is up +#define MG_TCPIP_STATE_READY 2 // Interface is up and has IP }; void mg_tcpip_init(struct mg_mgr *, struct mg_tcpip_if *); diff --git a/src/tcpip/driver_stm32.c b/src/tcpip/driver_stm32.c index 0cb74cb4..3d3a1d77 100644 --- a/src/tcpip/driver_stm32.c +++ b/src/tcpip/driver_stm32.c @@ -178,7 +178,7 @@ static size_t mg_tcpip_driver_stm32_tx(const void *buf, size_t len, static bool mg_tcpip_driver_stm32_up(struct mg_tcpip_if *ifp) { uint32_t bsr = eth_read_phy(PHY_ADDR, PHY_BSR); bool up = bsr & BIT(2) ? 1 : 0; - if ((ifp->state == MIP_STATE_DOWN) && up) { // link state just went up + if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up uint32_t scsr = eth_read_phy(PHY_ADDR, PHY_CSCR); uint32_t maccr = ETH->MACCR | BIT(14) | BIT(11); // 100M, Full-duplex if ((scsr & BIT(3)) == 0) maccr &= ~BIT(14); // 10M diff --git a/src/tcpip/driver_stm32h.c b/src/tcpip/driver_stm32h.c index 5c5b3d20..2567f95d 100644 --- a/src/tcpip/driver_stm32h.c +++ b/src/tcpip/driver_stm32h.c @@ -233,7 +233,7 @@ static size_t mg_tcpip_driver_stm32h_tx(const void *buf, size_t len, static bool mg_tcpip_driver_stm32h_up(struct mg_tcpip_if *ifp) { uint32_t bsr = eth_read_phy(PHY_ADDR, PHY_BSR); bool up = bsr & BIT(2) ? 1 : 0; - if ((ifp->state == MIP_STATE_DOWN) && up) { // link state just went up + if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up uint32_t scsr = eth_read_phy(PHY_ADDR, PHY_CSCR); uint32_t maccr = ETH->MACCR | BIT(14) | BIT(13); // 100M, Full-duplex if ((scsr & BIT(3)) == 0) maccr &= ~BIT(14); // 10M diff --git a/src/tcpip/driver_tm4c.c b/src/tcpip/driver_tm4c.c index f7a5d937..61bd5b0e 100644 --- a/src/tcpip/driver_tm4c.c +++ b/src/tcpip/driver_tm4c.c @@ -209,7 +209,7 @@ static size_t mg_tcpip_driver_tm4c_tx(const void *buf, size_t len, static bool mg_tcpip_driver_tm4c_up(struct mg_tcpip_if *ifp) { uint32_t bmsr = emac_read_phy(EPHY_ADDR, EPHYBMSR); bool up = (bmsr & BIT(2)) ? 1 : 0; - if ((ifp->state == MIP_STATE_DOWN) && up) { // link state just went up + if ((ifp->state == MG_TCPIP_STATE_DOWN) && up) { // link state just went up uint32_t sts = emac_read_phy(EPHY_ADDR, EPHYSTS); uint32_t emaccfg = EMAC->EMACCFG | BIT(14) | BIT(11); // 100M, Full-duplex if (sts & BIT(1)) emaccfg &= ~BIT(14); // 10M diff --git a/src/tcpip/tcpip.c b/src/tcpip/tcpip.c index 02330b2c..d6649861 100644 --- a/src/tcpip/tcpip.c +++ b/src/tcpip/tcpip.c @@ -173,7 +173,7 @@ static void arp_ask(struct mg_tcpip_if *ifp, uint32_t ip) { } static void onstatechange(struct mg_tcpip_if *ifp) { - if (ifp->state == MIP_STATE_READY) { + if (ifp->state == MG_TCPIP_STATE_READY) { MG_INFO(("READY, IP: %M", mg_print_ip4, &ifp->ip)); MG_INFO((" GW: %M", mg_print_ip4, &ifp->gw)); if (ifp->lease_expire > ifp->now) { @@ -181,10 +181,10 @@ static void onstatechange(struct mg_tcpip_if *ifp) { (" Lease: %lld sec", (ifp->lease_expire - ifp->now) / 1000)); } arp_ask(ifp, ifp->gw); - } else if (ifp->state == MIP_STATE_UP) { + } else if (ifp->state == MG_TCPIP_STATE_UP) { MG_ERROR(("Link up")); srand((unsigned int) mg_millis()); - } else if (ifp->state == MIP_STATE_DOWN) { + } else if (ifp->state == MG_TCPIP_STATE_DOWN) { MG_ERROR(("Link down")); } } @@ -354,7 +354,7 @@ static void rx_dhcp_client(struct mg_tcpip_if *ifp, struct pkt *pkt) { if (ip && mask && gw && ifp->ip == 0) { memcpy(ifp->gwmac, pkt->eth->src, sizeof(ifp->gwmac)); ifp->ip = ip, ifp->gw = gw, ifp->mask = mask; - ifp->state = MIP_STATE_READY; + ifp->state = MG_TCPIP_STATE_READY; onstatechange(ifp); tx_dhcp_request(ifp, pkt->eth->src, ip, pkt->dhcp->siaddr); uint64_t rand; @@ -737,16 +737,16 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t uptime_ms) { // Handle physical interface up/down status if (expired_1000ms && ifp->driver->up) { bool up = ifp->driver->up(ifp); - bool current = ifp->state != MIP_STATE_DOWN; + bool current = ifp->state != MG_TCPIP_STATE_DOWN; if (up != current) { - ifp->state = up == false ? MIP_STATE_DOWN - : ifp->enable_dhcp_client ? MIP_STATE_UP - : MIP_STATE_READY; + ifp->state = up == false ? MG_TCPIP_STATE_DOWN + : ifp->enable_dhcp_client ? MG_TCPIP_STATE_UP + : MG_TCPIP_STATE_READY; if (!up && ifp->enable_dhcp_client) ifp->ip = 0; onstatechange(ifp); } } - if (ifp->state == MIP_STATE_DOWN) return; + if (ifp->state == MG_TCPIP_STATE_DOWN) return; // If IP not configured, send DHCP if (ifp->ip == 0 && expired_1000ms) tx_dhcp_discover(ifp); @@ -930,7 +930,7 @@ void mg_mgr_poll(struct mg_mgr *mgr, int ms) { bool mg_send(struct mg_connection *c, const void *buf, size_t len) { struct mg_tcpip_if *ifp = (struct mg_tcpip_if *) c->mgr->priv; bool res = false; - if (ifp->ip == 0 || ifp->state != MIP_STATE_READY) { + if (ifp->ip == 0 || ifp->state != MG_TCPIP_STATE_READY) { mg_error(c, "net down"); } else if (c->is_udp) { struct connstate *s = (struct connstate *) (c + 1); diff --git a/src/tcpip/tcpip.h b/src/tcpip/tcpip.h index 677dba60..3bdcefea 100644 --- a/src/tcpip/tcpip.h +++ b/src/tcpip/tcpip.h @@ -15,32 +15,32 @@ struct mg_tcpip_driver { // Network interface struct mg_tcpip_if { - uint8_t mac[6]; // MAC address. Must be set to a valid MAC - uint32_t ip, mask, gw; // IP address, mask, default gateway - struct mg_str tx; // Output (TX) buffer - bool enable_dhcp_client; // Enable DCHP client - bool enable_dhcp_server; // Enable DCHP server - bool enable_crc32_check; // Do a CRC check on rx frames and strip it - bool enable_mac_check; // Do a MAC check on rx frames + uint8_t mac[6]; // MAC address. Must be set to a valid MAC + uint32_t ip, mask, gw; // IP address, mask, default gateway + struct mg_str tx; // Output (TX) buffer + bool enable_dhcp_client; // Enable DCHP client + bool enable_dhcp_server; // Enable DCHP server + bool enable_crc32_check; // Do a CRC check on rx frames and strip it + bool enable_mac_check; // Do a MAC check on rx frames struct mg_tcpip_driver *driver; // Low level driver void *driver_data; // Driver-specific data struct mg_mgr *mgr; // Mongoose event manager struct mg_queue recv_queue; // Receive queue // Internal state, user can use it but should not change it - uint8_t gwmac[6]; // Router's MAC - uint64_t now; // Current time - uint64_t timer_1000ms; // 1000 ms timer: for DHCP and link state - uint64_t lease_expire; // Lease expiration time - uint16_t eport; // Next ephemeral port - volatile uint32_t ndrop; // Number of received, but dropped frames - volatile uint32_t nrecv; // Number of received frames - volatile uint32_t nsent; // Number of transmitted frames - volatile uint32_t nerr; // Number of driver errors - uint8_t state; // Current state -#define MIP_STATE_DOWN 0 // Interface is down -#define MIP_STATE_UP 1 // Interface is up -#define MIP_STATE_READY 2 // Interface is up and has IP + uint8_t gwmac[6]; // Router's MAC + uint64_t now; // Current time + uint64_t timer_1000ms; // 1000 ms timer: for DHCP and link state + uint64_t lease_expire; // Lease expiration time + uint16_t eport; // Next ephemeral port + volatile uint32_t ndrop; // Number of received, but dropped frames + volatile uint32_t nrecv; // Number of received frames + volatile uint32_t nsent; // Number of transmitted frames + volatile uint32_t nerr; // Number of driver errors + uint8_t state; // Current state +#define MG_TCPIP_STATE_DOWN 0 // Interface is down +#define MG_TCPIP_STATE_UP 1 // Interface is up +#define MG_TCPIP_STATE_READY 2 // Interface is up and has IP }; void mg_tcpip_init(struct mg_mgr *, struct mg_tcpip_if *); diff --git a/test/mip_test.c b/test/mip_test.c index b796e48a..29db4d8c 100644 --- a/test/mip_test.c +++ b/test/mip_test.c @@ -22,7 +22,7 @@ static void test_statechange(void) { struct mg_tcpip_if iface; memset(&iface, 0, sizeof(iface)); iface.ip = mg_htonl(0x01020304); - iface.state = MIP_STATE_READY; + iface.state = MG_TCPIP_STATE_READY; iface.tx.ptr = tx, iface.tx.len = sizeof(tx); iface.driver = &mg_tcpip_driver_mock; onstatechange(&iface);