espressif / esp-lwip

Fork of lwIP (https://savannah.nongnu.org/projects/lwip/) with ESP-IDF specific patches
Other
79 stars 126 forks source link

dns: fix init with only IPv4 enabled (IDFGH-11392) #62

Closed cbaechler closed 5 months ago

cbaechler commented 8 months ago

When defining FALLBACK_DNS_SERVER_ADDRESS in a project where only LWIP_IPV4 is enabled, compiling dns_init will result in a compilation error:

esp-idf/components/lwip/lwip/src/core/dns.c: In function 'dns_init':
esp-idf/components/lwip/lwip/src/core/dns.c:328:12: error: 'ip_addr_t' {aka 'struct ip4_addr'} has no member named 'type'
   dnsserver.type = IPADDR_TYPE_V4;

This is due to the fact that ip_addr_t is defined as

typedef struct ip_addr {
  union {
    ip6_addr_t ip6;
    ip4_addr_t ip4;
  } u_addr;
  /** @ref lwip_ip_addr_type */
  u8_t type;
} ip_addr_t;

only if IPv4 and IPv6 support are enabled at the same time.

In the case where only IPv4 support is enabled, the definition of ip_addr_t is

struct ip4_addr {
  u32_t addr;
};

typedef struct ip4_addr ip4_addr_t;

typedef ip4_addr_t ip_addr_t;

which lacks the type field.

This PR aims to fix this and make it compile for our scenario.

KonssnoK commented 8 months ago

thanks @cbaechler

david-cermak commented 5 months ago

cherry-picked as 5aab73d78f22a3faf776c55dafb01136b97a54d9 to 2.1.3-esp and 1de11efadd0083469f26c8782be3d55073829767 to 2.1.2-esp.

Thanks for the contribution!