diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index 80d3c3ea..5e62b2af 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -673,9 +673,9 @@ dhcp_handle_ack(struct netif *netif, struct dhcp_msg *msg_in) if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SUBNET_MASK)) { /* remember given subnet mask */ ip4_addr_set_u32(&dhcp->offered_sn_mask, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SUBNET_MASK))); - dhcp->subnet_mask_given = 1; + dhcp->flags |= DHCP_FLAG_SUBNET_MASK_GIVEN; } else { - dhcp->subnet_mask_given = 0; + dhcp->flags &= ~DHCP_FLAG_SUBNET_MASK_GIVEN; } /* gateway router */ @@ -1088,7 +1088,7 @@ dhcp_bind(struct netif *netif) dhcp->t1_timeout = 0; } - if (dhcp->subnet_mask_given) { + if (dhcp->flags & DHCP_FLAG_SUBNET_MASK_GIVEN) { /* copy offered network mask */ ip4_addr_copy(sn_mask, dhcp->offered_sn_mask); } else { diff --git a/src/include/lwip/dhcp.h b/src/include/lwip/dhcp.h index 49c266e8..1a3bba01 100644 --- a/src/include/lwip/dhcp.h +++ b/src/include/lwip/dhcp.h @@ -62,6 +62,8 @@ extern "C" { #define DHCP_BOOT_FILE_LEN 128U +#define DHCP_FLAG_SUBNET_MASK_GIVEN 0x01 + /* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */ typedef enum { DHCP_AUTOIP_COOP_STATE_OFF = 0, @@ -78,8 +80,8 @@ struct dhcp u8_t state; /** retries of current request */ u8_t tries; - - u8_t subnet_mask_given; + /** see DHCP_FLAG_* */ + u8_t flags; u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */